[Kde-games-devel] Re: Quick question on QCanvasSprite

Andreas Beckermann b_mann at gmx.de
Mon Aug 4 01:40:35 CEST 2003


On Sunday 03 August 2003 05:09, Nathan Humbert wrote:
> How would someone go about rotating the graphics in a QCanvasSprite?
>
>
> Thanks,
> Nathan Humbert
> humbna at mirage.aswwc.net

Dunno what you mean by "quick" question...
Well, maybe an easy answer exists, but I doubt it, as QCanvasSprite operates 
on pixmaps only.
So I believe the "best" way to achieve this (and the only I can think of atm) 
is to rotate the sprites in advance and use an array (ahem: list) of rotated 
pixmap when constructing the sprite.
Yes, this takes a lot of memory. Yes,  you won't be able to use all rotation 
factors and yes, this situation is getting even worse if you are already 
using animations in your sprite (and then need to provide rotations for every 
frame).
You may be able to do some tricky code using QCanvasSprite::setSequence() in 
case you need animations. Then you can avoid storing several MB of pixmaps.

You can use QPixmap::xForm() to get a rotated pixmap, I guess. 
QWMatrix::rotate() should do nearly all of the work.

Are you sure you need rotations _and_ QCanvas? What kind of game/program are 
you doing?

CU
Andi


More information about the kde-games-devel mailing list