Carlos Posted June 10, 2015 Share Posted June 10, 2015 Hi,I have found that when an object has cacheAsBitmap property as true and the pivot of that object is changed, the body and input coordinates of that object doesn't get updated.You can see an example here:http://jsfiddle.net/cmnb/creL1vqm/ If you set cacheAsBitmap to false, the coordinates are updated to the right place. Link to comment Share on other sites More sharing options...
Carlos Posted June 11, 2015 Author Share Posted June 11, 2015 A hacky way to get over this is to offset the body subtracting the value used for the pivot.Now the body is aligned with the sprite but the input is still in the wrong place. var game = new Phaser.Game(800, 600, Phaser.CANVAS, null, {preload: preload, create: create, render: render});var sprite = [];function preload() { game.load.image('img', 'http://icons.iconarchive.com/icons/yusuke-kamiyamane/fugue/16/target-icon.png');}function create() { var group = game.add.group(game.world, 'group', false, true); for (var i = 0; i < 30; i++) { sprite[i] = group.create(game.world.randomX, game.world.randomY, 'img'); sprite[i].inputEnabled = true; sprite[i].events.onInputDown.add(hey, this); sprite[i].body.offset.setTo(-10, -10); } group.pivot.setTo(10, 10); group.cacheAsBitmap = true;}function hey() { alert('hey'); }function render() { for (var i = 0; i < sprite.length; i++) { game.debug.body(sprite[i]); } }You can see that the input coordinates for the onInputDown event are not aligned with the sprite in this fiddle:http://jsfiddle.net/cmnb/wdmxa36y/1/ Link to comment Share on other sites More sharing options...
Recommended Posts