Page 1 of 1
Display sprite over another
Posted: Fri Jun 02, 2006 6:44 pm
by yabune
Hi,
I have this code:
Code: Select all
DisplaySprite(thisFrame, 160, 120)
DisplaySprite(thisOverFrame, 160+3, 120+103)
FlipBuffers()
and it's in a loop so it looks like a movie, where I'm changing the frames.
The over frame should go on front of the thisFrame.
The problem is I get a white box on the second sprite..but if I pause the "movie" I can see that second sprite.
I tried to use two flipbuffers but it gets flicker.
Anyone knows how to solve this?
Thanks
A little more info?
Posted: Sat Jun 03, 2006 5:27 am
by GBeebe
So, what you're saying is that thisOverFrame is just a white box when it's not supposed to be? From what little code you've posted there are many possible reasons why that can happen...
If you're loading something other than a BMP, like a PNG file, you may experience that with Sprite2D stuff. Are you drawing on the sprite and maybe accidentally clearing it ClearScreen will affect it if you are doing UseBuffer(thisOverFrame). General things like that.
If you post a little more we can look into it deeper.
Re: A little more info?
Posted: Sat Jun 03, 2006 9:41 am
by yabune
GBeebe wrote:So, what you're saying is that thisOverFrame is just a white box when it's not supposed to be? From what little code you've posted there are many possible reasons why that can happen...
If you're loading something other than a BMP, like a PNG file, you may experience that with Sprite2D stuff. Are you drawing on the sprite and maybe accidentally clearing it ClearScreen will affect it if you are doing UseBuffer(thisOverFrame). General things like that.
If you post a little more we can look into it deeper.
Hi!
Yes, that's the problem, it shows a white box where it should appear a picture.
I'm using JPG pictures, and I don't use neither clearscreen and usebuffer.
I'm using like this:
Code: Select all
UseJPEGImageDecoder()
thisFrame.l = 1
thisOverFrame.l = 1
repeat
Delay(45)
DisplaySprite(thisFrame, 160, 120)
DisplaySprite(thisOverFrame, 160+3, 120+103)
FlipBuffers()
thisFrame = thisFrame + 1
thisOverFrame = thisOverFrame + 1
while thisFrame <= lastFrame
The thisFrame and thisOverFrame variables are the sprite identifiers of many pictures loaded with LoadSprite command.
The second sprite should show over the first, but I get a white box.
If I pause the loop, it looks all ok, but if I play it can't show the second sprite. But the first sprite goes ok.
Thank you for your help!
Try this:
Posted: Sat Jun 03, 2006 9:05 pm
by GBeebe
Add this line after FlipBuffers()
ClearScreen(0, 0, 0)
or if you are using PB 4
ClearScreen(0)
That should do it... I think, If not let me know and I'll try to think of something else.