Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Need help with animated sprite not disappearing.

Author
Message
Zeus6191
14
Years of Service
User Offline
Joined: 24th Oct 2011
Location:
Posted: 27th Nov 2011 21:24
So, I've read around the forum, but I'm still having difficulty with this. When I press rightkey() my character starts animating in the right direction, but my idle sprite doesn't disappear?
Can anyone point out what I'm doing wrong. I'm sure something is wrong with either the SPR_number or IMG_ number. Can someone explain the difference to me? Thank you.






---------------------
What the h4x...
Zeus6191
14
Years of Service
User Offline
Joined: 24th Oct 2011
Location:
Posted: 27th Nov 2011 23:00
I forgot to mention that I'm working with two bitmaps that I'm trying to animate.


---------------------
What the h4x...
Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 28th Nov 2011 00:23 Edited at: 28th Nov 2011 00:27
it looks like you are using sprite sprite,x,y,image to move and update your sprites during the Anim sub...

I use that command only once when setting up the sprite initially and then immediately hide it.

to update the new position/animation state use paste sprite sprite,x,y

I also like to have a HandleGraphics() function called at the end of the main loop which handles all of the paste, text, draw updates so that the screen can be cleared and sync'd in a single organized call. something like




Zeus6191
14
Years of Service
User Offline
Joined: 24th Oct 2011
Location:
Posted: 28th Nov 2011 00:46
When i used to the paste sprite command instead of the sprite num,x,y,img command my background shows as does my floor, but my character is nowhere to be seen. I believe the layer function is there to obviously correctly layer the sprite, but i unfortunately don't understand how it works as I've never used it and the code you posted isn't clear enough for me.

Is it possible you could show the example using my code so I could have something to work off of?


---------------------
What the h4x...
Zeus6191
14
Years of Service
User Offline
Joined: 24th Oct 2011
Location:
Posted: 28th Nov 2011 00:53
I've found that the image is actually animating behind the background. Like i said, having never used the commands you posted I'm unsure as to how to change the layer.


---------------------
What the h4x...
MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 29th Nov 2011 12:04
Omg Zeus please do not double post...

Use the Edit Post link just on the lower left and format it lkke this...


EDIT

And put your update here if nobody has replied yet.

EDIT

there is no annoyance as to how often you do it...

EDIT

Hope this helps.

Ortu
DBPro Master
18
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 30th Nov 2011 06:31
My example doesn't even bother with the actual sprite layer commands, I just have a layer variable in my UDT array for each sprites data. The for next loop cycles that value to paste things in the proper order



Type SpriteData
X as integer
Y as integer
Name as string
Show a Boolean
Layer as byte
End type

Dim sprites(maxsprite) as SpriteData


So then you would assign background sprites to sprites(sprite number).layer=1, character sprites wold go to the middle and ui images at the top. Use the .show flag to choose which sprites are visible and which are hidden. You can use the .name field to specify what it is =mycharacter, =floor, =prop =monster and/or set a variable to a sprites array index to reference it by name


Sprite 1,0,0,1 : myid=1
Sprites(myid).x=1
Sprites(myid).y=1
Sprites(myid).layer=5
Sprites(myid).show=1
Sprites(myid).name="player"



By putting all sprites into a type array, floors chars ui whatever you can handle all of the screen updates in a single simple loop.

Text has to be drawn last or it will get covered over

Ignore that keyX and keyY, they aren't really relevant to the process, they are just a pair of variables I use to maintain relative positioning across variable screen resolutions


Login to post a reply

Server time is: 2026-07-10 18:21:09
Your offset time is: 2026-07-10 18:21:09