Jump to content

animation.zh

Overview
Creator: grayswandir Added: 29 Apr 2014 Tags: Misc Downloads: 62
Rating[?]: No rating
View Script Download Example
(861.99 KB)
Information

Description Setup Reviews Comments

Requirements
This requires stdExtra.zh for the DirToXSpeed and DirToYSpeed functions - if you can live without dir based movement you can just delete that part of the code instead.

Constants
There are 2 constants, both of which should be fine as they are if you aren't running any other scripts. The first is the LW_ANIMATION, which is the weapon id you'll be assigning to animations. Don't let it overlap with any other weapons you're using.

The second is ANIMATION_ID_INDEX, which is which Misc slot of the lweapon you'll be storing the animation id in. You can change this to a different slot if it's interfering with an existing script.

Sprites
This uses sprites for animation, which you can define in ZQuest at Quest -> Graphics -> Sprites -> Weapons/Misc. It's probably easiest to make a constant for each sprite you'll be using.

Code
Call AnimationCreate(spriteId, x, y, loop) to create an animation lweapon. Set loop to true if you want it to continue forever, or false if you want it to stop after one time through the sprite.

Use AnimationGetId(animation) to get a unique id for each created animation, which will stay consistent between frames. Then use AnimationGet(id) to turn the id back into an animation for you to mess with.

If you call AnimationUpdate() in your main loop, then the animations will respect any of the normal movement values you'd give an lweapon, like Step and Dir and such. You can also call AnimationUpdate(animation) for a specific animation instead if you only want to move a specific one.


Resources

std.zh, stdExtra.zh, ffcscript.zh