Sign in to follow this  

How do I tween the rotation

Recommended Posts

... I've found a solution:

game.RotatableEntity = me.Entity.extend({
    init: function(x, y, sprite) {
        this._super(me.Entity, "init", [x, y, {
            width: sprite.width,
            height: sprite.height
        this.renderable = sprite;
        this.currentAngle = 0;
        this.prevAngle = 0;
    update: function() {
        this.prevAngle = this.currentAngle;
        return true;

Share this post

Link to post
Share on other sites

that's exactly what I do as well in one of my project, but in my case I pass an increment delta angle so that the object keep spinning (I just need then to negate the value if I want to reverse the rotation)

If you want to tween it, then you can either change the delta angle value passed to rotate, or change the target angle in your case.

Share this post

Link to post
Share on other sites

I don't get the delta in the callback. It seems to pass the current tween value in the 0-1 range except that for InOut easing, when reaching 1, instead of tweening back to 0 - it starts incrementing from 0.

Here's a fiddle:

        console.log( logo.currentAngle, val*maxAngle, (1-val)*maxAngle)


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.