Search the Community
Showing results for tags 'settileindexcallback'.
-
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;
-
Hello I try create callback function - when exist collision, but in phaser I found only this method: setTileIndexCallback - but this method disables collisions. map.setTileIndexCallback([9,10,11,12], function(){ console.log("callback and collision...?");}) Does anyone have an idea how to create a collision with a tile-map of the callback function?
-
Hi I am coding a small tilebased-top-down adventuregame. I'm learning Phaser as I go along, and I've discovered the setTileIndexCallback method. map.setTileIndexCallback(tileIndex, callBackFunction, this); It's working like a charm ... except for the fact that I only want it to trigger the callback function when my character enters the tile. It seems as though every Update() triggers the callback function as long as the player and the tile overlap. Is there any way to alter this behavior so it only triggers when the character enters the tile? Kind regards - Jakob