Animation Update and Trick

adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,159

So we finally got around to implementing Store Animation Frame To Attribute in the HTML5 engine. That's probably handy for someone out there.

We also had a request to adjust frame rate, but that's not really necessary in behavior because.... you can do it on your own!

This assumes that you have a common image name root and a 2 digit number after the name. So something like

'walk01' 'walk02' 'walk03', etc.

For this example we've also set up two Actor Attributes, FPS and FrameCount.

Then all you need is a constrain attribute as follows:

self.image = "walk"..padInt(ceil(mod(devices.clock.millisecond/1000*self.FPS,self.FrameCount)),2)

Hope that's handy for anyone looking to do something like this!

Comments

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,159

    A bit of an adjustment to avoid an extra calculations:

    "walk"..padInt(mod(ceil((scene.time)*(self.FPS)),self.FrameCount)+1,2)

    The +1 is because mod loops on a zero basis, so you need to add one to the loop. Alternatively, your animation could just start a frame 00.

    You can also avoid the "padInt" if you don't zero pad your frame numbers.

Sign In or Register to comment.