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

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.

Guest
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.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.