Sign in to follow this  
Growler

Sprite FlipX rotates full width on x axis

Recommended Posts

I'm following the MelonJS platformer tutorial again for 5.1 (used to be on 2.x).

For some reason basic this.renderable.flipX(true); causes the sprite to rotate the width of itself (64px) on the x axis?

Below, he's standing on the ledge. I tap left and he flips sprite, but is 65 pixels offset. How do I flip in place?

 

Screen Shot 2018-02-07 at 12.52.22 AM.png

Screen Shot 2018-02-07 at 12.52.46 AM.png

Share this post


Link to post
Share on other sites

This flips on the Y axis

game.PlayerEntity = me.Entity.extend({

    /**
     * constructor
     */
    init:function (x, y, settings) {
      this._super(me.Entity, 'init', [x, y, settings]);
      this.body.setVelocity(3, 15);
      me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);
      this.alwaysUpdate = true;
      this.renderable.addAnimation("walk",  [0, 1, 2, 3, 4, 5, 6, 7]);
      this.renderable.addAnimation("stand",  [0]);
      this.renderable.setCurrentAnimation("stand");
      // set the renderable position to bottom center
      this.anchorPoint.set(0.5, 1.0);
    },

Result

 

Screen Shot 2018-02-07 at 9.36.54 AM.png

Screen Shot 2018-02-07 at 9.36.58 AM.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.