Jump to content

getPixel not returning some colours


charlie_says
 Share

Recommended Posts

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.)

 

Charlie

var 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(){		}

post-54-0-15323600-1401790250.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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