HaxePunk / HaxePunk

Cross-platform desktop, mobile, and WebGL game engine, based on FlashPunk
MIT License
489 stars 126 forks source link

NumTween doesn't update on native ? #386

Closed matrefeytontias closed 8 years ago

matrefeytontias commented 8 years ago

Hi,

I've put together this simple test file to showcase that NumTween never updates:

import com.haxepunk.Scene;

import com.haxepunk.tweens.misc.NumTween;
import com.haxepunk.utils.Ease;

class MainScene extends Scene
{
    private var n:NumTween;
    public override function begin()
    {
        n = new NumTween();
        n.tween(512, 741, 1.0, Ease.quadInOut); // using no Ease function yields the same result
    }

    override public function update()
    {
        super.update();
        trace(n.value);
    }
}

I tried this on neko and cpp and it kept displaying 512 ; I tried with flash and html5 and nothing was being displayed. No reason why other tweens would work, but I didn't try.

azrafe7 commented 8 years ago

Hi, haven't tested it, but IIRC you have to register the tween by calling addTween(n) (condider it a really barebone Entity), so that it can be automatically updated every frame by the engine.

Side note: I always found HXP.tween() to be more intuitive to use, as it also adds it. In your case that would be something like this (assuming you want to tween the x property of object):

  object.x = 512;
  ...
  HXP.tween(object, { x: 741 }, 1.0, { ease: Ease.quadInOut });
matrefeytontias commented 8 years ago

Sorry for the late answer ; of course it now works, thanks for that.