Search code examples
animationplayn

How can we achieve animations in playN


I need to create some simple effects for the layers which I have created in my playN game. For instance, a layer starts as a line, resize on update, and thus slowly expands to full screen. Can I use triple play for this? For example: we can use setAlpha in update function to make a fading effect.


Solution

  • check out the Animator class from tripleplay, does exactly that

    code snippet:

    class MyGame extends Game {
        private Animator anim;
        private float _elapsed = 0;
    
        public void init() {
            anim = Animator.create();
    
            anim.tweenScale(aLayer).from(0).to(50).linear();
        }
    
        public void paint(float alpha) {
            anim.update(_elapsed + alpha * updateRate());
        }
    
        public void update(float delta) {
            _elapsed += delta;
        }
    }