// Update is called once per frame void Update() { if (!init) { Init(); init = true; } if (currentAnim != null) { if (!currentAnim.Idle) { FizzikFrame frame = currentAnim.GetFrame(currentFrame); if (currentPlaytime >= frame.Duration) { //Finished Frame if (IsLastFrame()) { //Reached Last Frame if (currentAnim.Loop) { if (currentAnim.PingPong) { //Ping Pong Loop pingpong = !pingpong; PlayNextFrame(); } else { //Regular Loop PlayAnimation(currentAnim.Name); } } else { //Switch back to default PlayAnimation(defaultAnimation); } } else { //Go to next Frame PlayNextFrame(); } } currentPlaytime += Time.deltaTime * animationSpeed; } } }
void Start() { FizzikAnimation anim = new FizzikAnimation(); anim.Name = "idle"; anim.Idle = true; FizzikFrame frame; //Frame 1 frame = new FizzikFrame(spriteIdle, 1f); anim.AddFrame(frame); // FizzikAnimationController controller = this.GetComponentInParent <FizzikAnimationController>(); controller.AddAnimation(anim); }
void Start() { FizzikAnimation anim = new FizzikAnimation(); anim.Name = "fire"; FizzikFrame frame; //Frame 1 frame = new FizzikFrame(spriteIdle, .025f); anim.AddFrame(frame); frame = new FizzikFrame(spriteFire, .075f); anim.AddFrame(frame); frame = new FizzikFrame(spriteIdle, .025f); anim.AddFrame(frame); // FizzikAnimationController controller = this.GetComponentInParent <FizzikAnimationController>(); controller.AddAnimation(anim); }
protected bool pingpong = false; // Whether or not the animation should play backwards once it reaches the end, requires looping /* * Adds a frame to the end of the frame list */ public void AddFrame(FizzikFrame frame) { frames.Add(frame); }