next fram - previous frame

0 favourites
  • 11 posts
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • I swear I search in the forums and tutorials but I coudn't find the action that let me set an animation to a previous or next frame.

    I'm making a prev and next buttons that, when clicked, will change the frame of an object; how can I do that?

    thanks!

  • You can use the animation controls within the sprite object:

    Event: On Button press -> Action: SpriteName -> Set frame (Frame number)

    EDIT// On re-read, you want a function that goes to the next frame instead of a specified one? Like AS nextFrame? That one I'm not so sure, you could manually specify each frame using the set frame action, but this may not be what your after

  • Event: On Button press -> Action: SpriteName -> Set frame (Frame number)

    But I should cover all the posibilities in events and actions? I mean, If the object is in frame 2, the prev button should set it to 1 and the next button should set it to 3, but, if the object is in frame 3 the buttons will still work like if it was in 2.

  • You can use the animation controls within the sprite object:

    Event: On Button press -> Action: SpriteName -> Set frame (Frame number)

    EDIT// On re-read, you want a function that goes to the next frame instead of a specified one? Like AS nextFrame? That one I'm not so sure, you could manually specify each frame using the set frame action, but this may not be what your after

    jajaja, sorry, didn't saw the edition. I guess that I should set every posibilty but I'm sure there must be an easier way to do it. If it isn't I would suggest it's integration for the next launch.

  • On Next pressed
      -> Sprite: Set frame to (self.frame+1)%self.Animationframecount
    On Prev pressed
      -> Sprite: Set frame to self.frame = 0 ? self.Animationframecount-1 : self.frame-1
    

    Should work fine

  • On Next pressed
      -> Sprite: Set frame to (self.frame+1)%self.Animationframecount
    On Prev pressed
      -> Sprite: Set frame to self.frame = 0 ? self.Animationframecount-1 : self.frame-1
    

    Should work fine

    I'm trying to use it but it says

    "frame" is not an expression or instance variable in "Object"

    Any idea?

    Thanks anyway!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • yeah it's self.AnimationFrame

    you know, every object property will appear after you type 'self.' so well... you just had to pick the one which made more sense, and seriously, rtfm (:

  • Thanks, it works perfectly.

    But, let's be clear.. the manual isn't a InDeep explanation of the functions and is not even close. Lot of information that could be clearified in the manual is actually in the forums (even this simple function to prev and next an animation could be cleared out in the manual in the Animation controlling section).

    Either way,I'll check it out in the future just in case.

    bye

  • On Next pressed
    -> Sprite: Set frame to (self.frame+1)%self.Animationframecount
    On Prev pressed
    -> Sprite: Set frame to self.frame = 0 ? self.Animationframecount-1 : self.frame-1
    

    Should work fine

    Thanks. This helped me. But how can I do something like this, but advance to the next animation if all animations are numbered sequentially?

  • KENYONB Say, your animations are named A0, A1, A2..

    On Next pressed
     Sprite compare frame = (Sprite.animationFrameCount-1)
     	Sprite set animation "A" & (int(replace(Sprite.AnimationName,"A", ""))+1)
     Else 
    	Sprite set frame to (Sprite.AnimationFrame+1)
    
  • Thanks dop2000 I ended up using still frames in one animation, but I will try this in another project and see if it works.

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