charlie_says Posted June 3, 2014 Share Posted June 3, 2014 I've found that getPixel sometimes doesn't return a colour, usually greens/blues, anyone got any ideas what's going wrong (I don't think it's my code, but I'm happy to be corrected.) Charlievar game = new Phaser.Game(400, 400, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update });var img1, img1BMD;function preload(){ game.load.spritesheet('target3',' images/target3.png', 70, 100, 8); game.stage.backgroundColor = 0x888888;}function create(){ img1BMD = game.make.bitmapData(630, 100); img1BMD.draw(game.cache.getImage('target3'), 0, 0); img1BMD.update(); img1 = game.add.sprite(100,100,"target3"); img1.animations.add('float', [0,1,2,3,4,5,6,7], .25, true); img1.animations.play('float'); img1.inputEnabled = true; //info.onTap.add(this.info_clicked, this); img1.events.onInputDown.add(clicky, this);}function clicky(img, pointer){ var posX,posY; posX = pointer.x - img.x; posY = pointer.y - img.y; var frame = img1.animations.currentAnim.frame; console.log("frame:"+frame, "x:"+posX, "y:"+posY, img1BMD.getPixel(posX+(frame*70),posY));}function update(){ } Link to comment Share on other sites More sharing options...
charlie_says Posted June 3, 2014 Author Share Posted June 3, 2014 And, I've just noticed that getPixel32 returns undefined in Safari (both desktop and iPhone) Link to comment Share on other sites More sharing options...
charlie_says Posted June 4, 2014 Author Share Posted June 4, 2014 Ok - I've created a fiddlehttp://jsfiddle.net/FxjL8/8/Clearly shows the issue - green & blues return incorrect information for getPixel. getPIxel32 returns correct info, except in Safari where it returns undefined Link to comment Share on other sites More sharing options...
charlie_says Posted June 4, 2014 Author Share Posted June 4, 2014 Having read through the Phaser code, I did just think that I should call bitmapData.update() prior to using getPixel - even though the bitmapData hasn't changed...new fiddle:http://jsfiddle.net/FxjL8/9/Same issues still apply. Link to comment Share on other sites More sharing options...
Recommended Posts