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! / Problem with changing animated sprite frames

Author
Message
A_Human
11
Years of Service
User Offline
Joined: 21st Feb 2011
Location:
Posted: 5th Mar 2011 07:36
I'm trying to figure out how to make my animated sprite change frames when shooting, hit, hit while shooting, etc. I've tried using If statements in conjunction with the Set Sprite Frame command but, as i soon learned, that would set the frame indefinitely. Then i tried using Repeat/Until statements to check for input and then end the loop when the correct key was not being pressed. Finally, i tried using while loops, but that seemed to only freeze the program while the key to shift frames was being pressed. I'm uploading the entire source file so you guys can see. BTW, this is my first attempt at a 2d game so please don't be too harsh on my skill level. There's also a lot of unneeded code in there that i was using earlier for a different method at going at things.

Attachments

Login to view attachments
LBFN
15
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 5th Mar 2011 15:27
It would be helpful to have the media associated with the project. Any chance you can put it in a zip / rar file and post it up here?

A_Human
11
Years of Service
User Offline
Joined: 21st Feb 2011
Location:
Posted: 5th Mar 2011 17:53
Sure. Here's the media.

Attachments

Login to view attachments
LBFN
15
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 5th Mar 2011 20:14 Edited at: 13th Mar 2011 14:31
EDIT: Taking a closer look at it; I guess I shouldn't post when in such a hurry.

Generally, I never use DISABLE ESCAPEKEY unless I provide a way for the user to exit the game. The way it ran, the game hung up and I had to CNTRL - ALT - DELETE to get out. Normally, I will check keystate(1) for this.

Instead of using 9 different covers, why not use an array (like this)

instead? Then you can do things like this:

and this


which take less typing and are easier to read.

As to the sprite frames problem, it seems that you are creating the animated sprite frames fine, but that you do not actually animate the sprites. In this case, it might be easier to grab the sprite images yourself, instead of using CREATE ANIMATED SPRITE. Setting the sprite image at that point should work fine.

Login to post a reply

Server time is: 2022-12-06 03:52:07
Your offset time is: 2022-12-06 03:52:07