Change the default animation speed of a sprite at runtime

0 favourites
  • 5 posts
From the Asset Store
Have you ever dreamed of playing in a Speedball game or tournament?
  • Hello!

    How do I change the default animation speed of a sprite at runtime so that all the new sprites created onward will have the new value?

    The reason of this is that every level has its own timing setting read in by level data file and then I want to adjust the animations to reflect that.

    I know I could add hundreds of lines to include animation speed for every event instance new sprite is created, but it is a bit heavy (in particular since I only have one sprite object that consists of many different sets of graphics.... it is a puzzle game with potentially 600 sprites on screen) so I wonder if it is possible to change the default speed at runtime.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set a global variable to the speed value, then the event would be 'on sprite created set animation speed to global variable', so one event for all sprites. Updating that global variable is up to you, maybe it changes based on the current level or something like that.

  • Thank you for replying!

    It looks like it will only change the animation of the active animation of the sprite, and not all the animations in the sprite.

    Also when I change animation to play another animation (in the sprite), it will revert to the original speed.

    I will try to solve this meanwhile.

  • You can apply the set speed action with the GV on the events when you change animation too.

  • Yeah I could do that. But I would need to edit a lot of events.

    I did a ugly workaround now: by changing timescale instead. I think it will work better this way. I can always adjust the count down timer accordingly so it ticks down in same speed.

    EDIT: I didn't even have to adjust the countdown timer as it was running independent from timescale.

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