Can you post a code snippet? This is about the 3rd time this problem has
come up in the past few months. Its a problem in your code, not SDL.
Everytime a surface moves out of the screen (completly or just with one
Pixel) it disapears and it doesn’t gets visible if i move it in again. I want
that the surface moves smooth out and into the screen.
How can i manage this ?
Thanx
–
Sent through GMX FreeMail - http://www.gmx.net
Actually, the problem is likely what Bill Kendrick stated previously.
If you blit something that overlaps the edge of the destination surface
(here screen) without making your destination and source rectangles sized
appropriately (i.e., it really does overlap the edge of the screen) then
SDL dumps the surface and you must reload the artwork and reblit.
When you move in or out of the screen, make sure your source and
destination rectangles adjust accordingly. A simple example (not
necessarily universal, alter it according to your needs) is
SDL_Rect dest;
SDL_Surface *sprite; //the image to blit
SDL_Surface *screen; //the screen surface
//—STUFF HAPPENS
dest.x = x; // wherever you want it to finally be
dest.y = y; // also
if( (dest.x + sprite->w) > (screen->w - 1) ) //I like to play it safe,
//so I do screen->w -1
dest.w = screen->w - dest.x - 1;
else
dest.w = sprite->w;
//then do the same thing for dest.h and similar things for your source
//rectangle…
(note: I whipped this example out in 30 seconds… please disregard any
errors and focus on the content… thx
or take a look at the now defunct SDL_PLus code fragment for blitting at
http://www.physics.arizona.edu/~hart/temp/tuxtype/tuxtype/SDL_Plus.cOn Tue, 23 May 2000, Martin Donlon wrote:
On Tue, 23 May 2000 gamsta at gmx.net wrote:
–
Sam Hart http://www.physics.arizona.edu/~hart/
Web Page Highlights: Video Game History, Black Hole Simulation, & more.
OTHER WEB SITES MAINTAINED BY SAM HART
http://www.geekcomix.com/ - Geekcomix, the Daily Geek Comic Strip Site
http://www.physics.arizona.edu/~hart/gw/ - Ghostworks (Alt./Linux Computing)