Jump to content

Is it possible to rotation the body?


khleug35
 Share

Recommended Posts

I would like to create slopes platform and make the player stand on it

I  use rotation method, it is work on sprite , but not work in body.......any idea, thank you very much

 

game.addAsset('sprite.png');

game.createScene('Main', {
    init: function() {        
        this.sprite = new game.Sprite('sprite.png');
        this.sprite.anchor.set(50, 50);
        this.sprite.position.set(game.width / 2, game.height / 2);
        this.sprite.addTo(this.stage);

        var shape = new game.Rectangle();
        shape.width = this.sprite.width;
        shape.height = this.sprite.height-20;
        this.body.addShape(shape);
        this.body.addTo(game.scene.world);   
    },

    update: function() {
        this.sprite.position.copy(this.body.position);

        this.sprite.rotation = 0.4;
        this.body.rotation = 0.4;  // not work
    }
});


 

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.

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

  • Recently Browsing   0 members

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