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.

2D All the way! / Sprite Animation Issues :(

Author
Message
thaman978
12
Years of Service
User Offline
Joined: 27th Nov 2011
Location:
Posted: 30th Dec 2012 04:52
So I am attempting to make an animated game using sprites. This my first time and I'm a bit confused :/. I have everything working except I don't know how to make an animation continue after a button is pressed. I have it so the "z" key does an attack, but you have to hold the key down for the animation to play fully, and if you hold it down to long it just restarts the attack animation its incredibly irritating!
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 30th Dec 2012 05:17 Edited at: 30th Dec 2012 05:17
What language are you in?

Otherwise, what you need to do is have say an isattacking# variable that you can check each loop if the character is attacking or not. If he's not then allow the 'z' key to be pressed, if he is attacking then disable the 'z' key press and play the sprite animation.

thaman978
12
Years of Service
User Offline
Joined: 27th Nov 2011
Location:
Posted: 30th Dec 2012 06:17
I'm using Dark Basic Pro. Umm.. It may be because I'm tired but I'm not fully understanding you. Could you post an example code?
thaman978
12
Years of Service
User Offline
Joined: 27th Nov 2011
Location:
Posted: 30th Dec 2012 14:40
Well I still haven't fixed my animation issue and now I'm having more issues!! Is it possible to make a slanted sprite?? I made a hill, then a hill barrier, but the hill barrier was made in a very large box so that way it could fit the entire thing. That probably sounds confusing, so instead I ask this: How can I just rotate a sprite?
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 1st Jan 2013 04:52 Edited at: 1st Jan 2013 04:57
I assume you are using CREATE ANIMATED SPRITE, along with PLAY SPRITE for the animations (it would help if you posted the relevant code here).

PLAY SPRITE needs to be called every time the sprite movement code is executed, not just when the input is registered. You cannot call it one time and have it work.

EDIT: Also, DB Pro has a ROTATE SPRITE command.

So many games to code.....so little time.
thaman978
12
Years of Service
User Offline
Joined: 27th Nov 2011
Location:
Posted: 1st Jan 2013 22:13
I do use play sprite every time, but DBPro starts the sprite off at last frame that was used no matter what frame you have as the "start frame". And I used the rotate sprite command but it still acted like it was not rotated.
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 2nd Jan 2013 01:05
PLAY SPRITE has some oddities and some people don't even bother with it and manually animate sprites themselves. However, if you can learn how it works, it can be an effective command to use. When you call it after it has already played something else, you need to set the sprite frame to the first image you want to use when you call it again. To give you an example, lets say you want to play frames 3 to 8 (held in the variables, StartAnim and EndAnim) and the number of the sprite is held in the variable, SprNum. You would use

PLAY SPRITE SprNum,StartAnim,EndAnim,delay would still have to be used in every iteration of the code. So in normal use, lets say the player is moving up and then moves right. When you register the input to go right, you would set the sprite frame to the first frame in the moving right animation.

ROTATE SPRITE works well, so there must be something in your code that needs to be changed. I can't help you with that unless you post up the section of code that you are using.

Hope this is helpful.

So many games to code.....so little time.

Login to post a reply

Server time is: 2024-03-28 12:17:15
Your offset time is: 2024-03-28 12:17:15