Jump to content

setTileIndexCallback context


Ansimuz
 Share

Recommended Posts

I'm trying to change the velocity of an object with a callback from "setTileIndexCallback" but with no luck. I can read its body velocity but cannot set it.

 

Slug = function (game, x, y) {
    x *= 16;
    y *= 16;
    Phaser.Sprite.call(this, game, x, y, "atlas", "slug/slug-1");
    this.animations.add('crawl', Phaser.Animation.generateFrameNames('slug/slug-', 1, 4, '', 0), 10, true);
    this.animations.play("crawl");
    this.anchor.setTo(0.5);
    game.physics.arcade.enable(this);
    this.body.setSize(20, 11, 7, 10);
    this.body.gravity.y = 500;
    this.body.velocity.x = 40;
    this.body.bounce.x = 1;


    globalMap.setTileIndexCallback(3, function(){ console.log(this.body.velocity.x); this.body.velocity.y =  -50; }, this);
}
Slug.prototype = Object.create(Phaser.Sprite.prototype);
Slug.prototype.constructor = Slug;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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