swapping sprite animations

0 favourites
From the Asset Store
Full game Construct 2 capx code source to post on Google Play
  • 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...

    dwbailey.com/images/SquirrelNuts

    here is the link to play it....

  • What's the issue you're having?

  • 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.

  • i should say, each time you collect the nut, it disappears and the Acorn counter goes up...

  • 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....

  • (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)

  • 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

  • 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.

    <img src="https://dl.dropboxusercontent.com/u/98084707/Help5.jpg" border="0" />

    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.

  • <img src="https://dl.dropboxusercontent.com/u/98084707/Help6.jpg" border="0" />

  • also what about the different states of animation...so I collect more than 10 acorns..my animation switches..but how can i get it to switch for each state...when i press left..press right...and attack...?

  • s93.photobucket.com/user/spawn85027/media/animationSetupsofar_zpsaced40e4.jpg.html

    this is what i have so far but it isnt working?

  • Okay, since I see you have 2 sets of animations ready, you will just need to add sub-events to your already existing movement and attack methods to take advantage of their second state. Hopefully this screencap will better explain then. Note what I have shown for the "On right arrow pressed" will need to be replicated for the other movements, attack, and jump.

    <img src="https://dl.dropboxusercontent.com/u/98084707/Help7.jpg" border="0">

    Here's a small .capx showing the states changing with the above- demonstrated method.

    SwapAnimationHelp

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • so I had a player box...and a sprite for my animations...the player box had the behavoirs..platform and scroll to...anyway i never used instance variables before until now..sorry its 243am...my head hurts ha..so i went and rearranged my player....and got idle sprite to move around again...but for some reason when i put that scroll behavoir back on him, i can no longer see the sprite, also the screen moves to a position that my sprite is not at...i can move left and right but not jump...helll not sure what is going on....

    i guess i can just upload the project...how do i do that..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)