phaser/examples/wip/priority.js
photonstorm ab5c07dfe8 Updated to Pixi 1.5 final.
InputHandler.pixelPerfectOver - performs a pixel perfect check to see if any pointer is over the current object (warning: very expensive!)
InputHandler.pixelPerfectClick - performs a pixel perfect check but only when the pointer touches/clicks on the current object.
2014-02-12 01:25:36 +00:00

42 lines
1.1 KiB
JavaScript

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.atlas('seacreatures', 'assets/sprites/seacreatures_json.png', 'assets/sprites/seacreatures_json.json');
}
var sprite1;
var sprite2;
var sprite3;
function create() {
sprite1 = game.add.sprite(200, 300, 'seacreatures', 'blueJellyfish0000');
sprite2 = game.add.sprite(230, 300, 'seacreatures', 'crab10000');
sprite3 = game.add.sprite(280, 250, 'seacreatures', 'seahorse0000');
sprite1.inputEnabled = true;
sprite2.inputEnabled = true;
sprite3.inputEnabled = true;
sprite1.input.priorityID = 0;
sprite2.input.priorityID = 1;
sprite3.input.priorityID = 2;
sprite1.input.pixelPerfectClick = true;
sprite2.input.pixelPerfectClick = true;
sprite3.input.pixelPerfectClick = true;
sprite1.events.onInputDown.add(clicked, this);
sprite2.events.onInputDown.add(clicked, this);
sprite3.events.onInputDown.add(clicked, this);
}
function clicked(s) {
console.log('clicked', s.frameName);
}