PDA

View Full Version : Flipping images is a nightmare!



enker
15-07-2004, 06:39 PM
I'm trying to do this platform game, and I want to flip the sprites when the player moves to the opposing part of the screen. My problem is that I don't know how to flip an sprite (I don't want to do two animations per move, like walking tto the left, walking to the right, etc...).

I have tried to do a StretchDraw with the x coordinates of the TRect swapped, but the StretchDraw of the TDXImageList doesn't support that and instead I get nothing.

In my second attempt, I tried to use the StretchDraw from the Canvas, in the surface. I manage to flip the image, but it doesn't draws it with tranparency.

I'm getting frustrated with something so simple, and I don't want to do two animations per moves (you know, my image library will get a tremendous size).

Traveler
16-07-2004, 08:45 AM
IIRC there was a thread about this some time ago. Not sure if it included a solution though.

In any case. There's no flipping images function in DelphiX. If you want to do this, then you'll need to write it yourself. It should be posssible with scanline.

IMO I think its much less of a hassle to go through making the extra images.

cairnswm
19-07-2004, 09:48 AM
Or write a program to externally flip all your images. Then you dont have the hard work to do. A program will need a very large amount of images to cause a screen card memory problem anyway.

enker
19-07-2004, 03:05 PM
Thanks for the ideas, I'm starting to consider the extra sprites (for this game). Still, I'm interested in making the images flip on run-time, because I'm going to start a big project soon, and I'll need this function (I have to economize a little).

I'm going to try with scanline, thanks again!

Huehnerschaender
13-08-2004, 09:34 AM
I'm trying to do this platform game, and I want to flip the sprites when the player moves to the opposing part of the screen. My problem is that I don't know how to flip an sprite (I don't want to do two animations per move, like walking tto the left, walking to the right, etc...).

I have tried to do a StretchDraw with the x coordinates of the TRect swapped, but the StretchDraw of the TDXImageList doesn't support that and instead I get nothing.

In my second attempt, I tried to use the StretchDraw from the Canvas, in the surface. I manage to flip the image, but it doesn't draws it with tranparency.

I'm getting frustrated with something so simple, and I don't want to do two animations per moves (you know, my image library will get a tremendous size).

There is a function within DIB.pas called mirror. You can choose if you want to mirror horizontally or vertically. Did you took a look at it?

Greetings,
Dirk

enker
24-08-2004, 01:49 AM
Nope, but seems like a very good option! thanks for the help!

peterbone
08-09-2004, 02:11 PM
It's very easy to flip a tbitmap horizontally with scanline


for y := 0 to Bitmap.Height - 1 do begin
LRowIn := Bitmap.Scanline[y];
LRowOut := BitmapOut.Scanline[y];
for x := 0 to Bitmap.Width - 1 do begin
LRowOut[x] := LRowIn[Bitmap.Width - x - 1];
end;
end;

something like that (not tested).