swapping sprite animations

Get help using Construct 2

Post » Thu Oct 10, 2013 7:29 am

I have a question. I am trying to swap out my player animations.

When the player collides with 10 nuts, he cant jump as high and his sprite animations will change to a sprite that shows that his sack is full...


I have a walk animation, attack animation, idle animation...right now...

http://www.dwbailey.com/images/SquirrelNuts/

here is the link to play it....
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 7:38 am

What's the issue you're having?
B
47
S
17
G
82
Posts: 2,232
Reputation: 48,611

Post » Thu Oct 10, 2013 7:54 am

well i don/t know how to set up the system of ...when the player collides with sprite ten times...change to these sets of animations.
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 7:55 am

i should say, each time you collect the nut, it disappears and the Acorn counter goes up...
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 7:58 am

basically the gameplay is this...when the player collides with the Acorn, the acorn counter goes up 1..and the acorn disappears...after the player collections 10 acorns, their bag is full...and sprite animations switch to represent the graphics of being full....when the nuts in the bag have been dumped off(player will press down at the home tree) the player sprite goes back to original state....
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 7:58 am

(It seems you were responding to this while I was typing my reply, so it appears you already knew this)

First of all, you've done nice work so far! I wasn't able to press the Down arrow key to store the acorns at the "Home" location, but was still looking good!

If I understand your question correctly, a simple solution would be to add a local variable to your squirrel (AcornCount for example), have that local variable increase by 1 every time it collides with an acorn sprite, then upon that local variable becoming greater than or equal to 10, change the squirrel's animation to your "loaded bag" one. From that point it would be quite simple to reverse the process by resetting that variable to 0 upon completion of a level, etc., to allow it to go back to its original "unfilled" state. This would also serve as the trigger for making the squirrel unable to jump quite as high.

What you will have to decide, however, is artistically which method you would want to use to have the 2nd "bag full" animation. The two ideas that come to mind are simply copying all your animations a 2nd time in whatever image editor you are using and alter the bag to being full, then importing these second sets as "Walk_Full", or "Attack_Full", so that you have something to change them to when the count reaches 10.

The second option would be to redo the animations you have currently where the bag itself is not present, then create 2 static sprites of the bag (one empty, one full). Prior to the variable being 10, have the empty bag sprite either pinned to the back of your squirrel, or have it create the empty bag sprite once, then set its location to the squirrels image point each tick. Once the variable count is equal to or greater than 10, you would only have to change the empty bag sprite to the full bag sprite and repeat its pinning or location tracking.

Long story short for the 2 options i've suggested: make 2 sets of every animation, or modify the 1 set you have and swap out 1 image.

Keep up the good work! (sorry for the lengthy wall of text)jktozier2013-10-10 07:59:12
B
5
Posts: 11
Reputation: 623

Post » Thu Oct 10, 2013 8:02 am

thanks for the reply, im trying to figure out the

then upon that local variable becoming greater than or equal to 10, change the squirrel's animation to your "loaded bag"

not sure how to do this part
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 8:19 am

http://s93.photobucket.com/user/spawn85027/media/collisionanimaotinchange_zpsf82e73b3.jpg.html
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Thu Oct 10, 2013 8:25 am

No problem! Basically if you have another animation attached to your squirrel in the editor that corresponds to "when the bag is full" (Run_Bag_Full) or whatever you ended up calling it, set an event that Compares the Instance Variable AcornCount >/= 10. When this is true, set animation to "BagFullWalk"/"BagFullJump"/"BagFullAttack" or whatever you chose to name them.



The above illustrates how you could do this if you were making another set of animations. If you were only swapping between an empty or full bag image, you would simply create another frame for your bag in the animation editor, put the bag full image as the other frame, set its animation speed to 0, then use the same method as changing animations listed above, except only change the frame of the bag to the # of the full bag frame (in this example, change from frame 0 (empty) to frame 1 (full)). Make sure you set this 2-frame bag animation's speed to 0, or else it will swap frames on its own upon loading the game, which you don't want, you want to drive that frame change with the events.
B
5
Posts: 11
Reputation: 623

Post » Thu Oct 10, 2013 8:32 am

B
5
Posts: 11
Reputation: 623

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests