Jump to content

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

Link to comment
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]);
      // set the renderable position to bottom center
      this.anchorPoint.set(0.5, 1.0);



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

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

Link to comment
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.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...