Scrolling Game Development Kit Forum

SGDK Version 1 => Help/FAQ => Topic started by: timmyslasttry on 2005-03-24, 07:56:26 AM

Title: change player state when shooting
Post by: timmyslasttry on 2005-03-24, 07:56:26 AM
I need to change my player's expression when shooting fireballs.  I have the shooting part down, I just don't know how to cycle in the frame of the player's shooting motion.  Please help.
Thanks!
Title: Wie fiele?
Post by: durnurd on 2005-03-24, 10:30:58 AM
How many times would you say that's been addressed, Red three?

*chkst* I'd say about three on the guns, three on the towers *chkst*

So, you have a walking sprite (left/right for this example) that has, say, 6 frames in each animation (6 for walking left, 6 for walking right).  Then, create a sprite that has 6 frames of animation for each shooting state (6 for shooting left, 6 for shooting right).

Create an invisible inventory item called "isNotShooting", initial value 3, max 3.

Then, create a global special function that is activated when the fire button is pressed, which requires 2 isNotShooting inventory and uses them up which does the "Switch to a new sprite" function.  Switch to the firing sprite, retain old state, in same location as old, delete old sprite.

Create another global special function that adds one to the isNotShooting inventory constantly.

And finally, create a third special function that requires three isNotShooting inventory which switches back to the old sprite, same flags as the first special function.
Title: Thanks, but still need help
Post by: timmyslasttry on 2005-03-24, 01:42:36 PM
You've got me on the right direction , but I still can't get it to work.  My sprite just disappears.  Maybe is has something to do with the 2nd, special function, I don't see anything about 'adding' or 'continuously'  Did you mean add player interaction?  Please help.  I'm a beginner, so you'll have to be pretty descriptive.  THANKS.
-Ryan
Title: change player state when shooting
Post by: bluemonkmn on 2005-03-25, 06:24:51 AM
Can you think of anything in your project/design that would cause the player sprite to be deleted?  The only thing I can think of is the "Delete old sprite" checkbox on the switch to sprite function.  But that should never leave the sprite completely gone because it should always be creating a new sprite at the same time... unless maybe you switched to the same sprite that you are deleting.
Title: re:
Post by: timmyslasttry on 2005-03-25, 09:16:36 AM
Here's where my hangup is:


Create another global special function that adds one to the isNotShooting inventory constantly.

I don't understand.

Please clarify.

Thanks.
Title: change player state when shooting
Post by: durnurd on 2005-03-27, 02:11:41 PM
Create a special function in the Special Functions tab.  The function is to "alter inventory".  Have it add 1 to the isNotShooting inventory.  Check "Global (Covers entire map)" in the activation parameters.

That's it.
Title: Reasoning
Post by: bluemonkmn on 2005-03-28, 06:59:21 AM
The purpose if the function that adds 1 to isNotShooting is to "notice" when you stop shooting.  As long as you continue to shoot, you will continue to use up these items faster than they can be replenished, but once you stop pressing the button, the function in question will allow the count of isNotShooting to get back up to 3, and when that happens the other function can activate that switches the sprite back to the non-shooting state.
Title: change player state when shooting
Post by: Guest on 2005-04-29, 07:30:30 AM
I tried the technique but my sprite just flickers and moves slowly. Is there any way to fix this?
Title: change player state when shooting
Post by: bluemonkmn on 2005-05-01, 07:12:25 AM
I tried a small test project and noticed that this method isn't perfect.  However I did notice one important possibility for improvement.  It works better if you check the box for "new instance" on your switch sprite functions, otherwise it will delete the player sprite half the time (causing it to flicker).  I guess there's still room for improvement in the GameDev engine there.  This might not be perfect, but it'll be a little better.  I haven't had time to come up with a better suggestion.
Title: Re: change player state when shooting
Post by: eric22222 on 2006-01-09, 06:35:05 PM
Hey, that's a really good idea! I'm gonna tweak that so my player is temporarily invulernable when he's hit! Thanks  :)