Skip to content

Commit

Permalink
[#580] "showcase" the new ability
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Jan 10, 2018
1 parent 6d796e3 commit 06c64f7
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions examples/platformer/js/entities/coin.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
game.CoinEntity = me.CollectableEntity.extend({
game.CoinEntity = me.Sprite.extend({
/**
* constructor
*/
init: function (x, y, settings) {

// call the super constructor
this._super(me.CollectableEntity, "init", [x, y , settings]);

// add the coin sprite as renderable
this.renderable = game.texture.createSpriteFromName("coin.png");

// set the renderable position to center
this.anchorPoint.set(0.5, 0.5);
this._super(me.Sprite, "init", [
x, y ,
Object.assign({
image: game.texture,
region : "coin.png"
}, settings)
]);

// add a physic body
this.body = new me.Body(this);
this.body.addShape(new me.Ellipse(this.width / 2, this.height / 2, this.width, this.height))
// set the collision type
this.body.collisionType = me.collision.types.COLLECTABLE_OBJECT;
// enable physic
this.isKinematic = false;
},

/**
Expand Down

0 comments on commit 06c64f7

Please sign in to comment.