Input priority IDs working properly for drag events.

This commit is contained in:
Richard Davey
2013-06-03 01:22:14 +01:00
parent 2270da2479
commit b951b02de8
22 changed files with 418 additions and 208 deletions
+5 -4
View File
@@ -9,12 +9,13 @@
var sprite;
function create() {
sprite = game.add.sprite(200, 200, 'sprite');
// Enable Input detection
// Enable Input detection. Sprites have this disabled by default,
// so you have to start it if you want to interact with them.
sprite.input.start(0, false, true);
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
// or if it will snap to the center (true)
sprite.input.enableDrag(true);
sprite.input.allowVerticalDrag = false;
//sprite.input.dragOffset.setTo(0, 50);
}
}
function render() {
game.input.renderDebugInfo(32, 32);
sprite.input.renderDebugInfo(300, 32);
+4 -4
View File
@@ -18,14 +18,14 @@
sprite = game.add.sprite(200, 200, 'sprite');
// Enable Input detection
// Enable Input detection. Sprites have this disabled by default,
// so you have to start it if you want to interact with them.
sprite.input.start(0, false, true);
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
// or if it will snap to the center (true)
sprite.input.enableDrag(true);
//sprite.input.allowVerticalDrag = false;
//sprite.input.dragOffset.setTo(0, 50);
}
function render() {
+22
View File
@@ -0,0 +1,22 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('sprite', 'assets/sprites/atari800.png');
game.loader.load();
}
var sprite;
function create() {
sprite = game.add.sprite(200, 200, 'sprite');
sprite.input.start(0, false, true);
sprite.input.enableDrag(true);
// The drag offset allows us to position the sprite relative to the pointer (+ lock) position
// In this case it will be positioned -100px above the pointer
sprite.input.dragOffset.y = -100;
}
function render() {
game.input.renderDebugInfo(32, 32);
sprite.input.renderDebugInfo(300, 32);
}
})();
+38
View File
@@ -0,0 +1,38 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('sprite', 'assets/sprites/atari800.png');
game.loader.load();
}
var sprite: Phaser.Sprite;
function create() {
sprite = game.add.sprite(200, 200, 'sprite');
sprite.input.start(0, false, true);
sprite.input.enableDrag(true);
// The drag offset allows us to position the sprite relative to the pointer (+ lock) position
// In this case it will be positioned -100px above the pointer
sprite.input.dragOffset.y = -100;
}
function render() {
game.input.renderDebugInfo(32, 32);
sprite.input.renderDebugInfo(300, 32);
}
})();
+28
View File
@@ -0,0 +1,28 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.loader.load();
}
var atari1;
var atari2;
var sonic;
function create() {
atari1 = game.add.sprite(100, 100, 'atari1');
atari2 = game.add.sprite(300, 200, 'atari2');
sonic = game.add.sprite(400, 300, 'sonic');
atari1.input.start(0, false, true);
atari2.input.start(1, false, true);
sonic.input.start(2, false, true);
atari1.input.enableDrag();
atari2.input.enableDrag();
sonic.input.enableDrag();
}
function render() {
game.input.renderDebugInfo(32, 32);
}
})();
+41
View File
@@ -0,0 +1,41 @@
/// <reference path="../../Phaser/Game.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, null, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
game.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
game.loader.addImageFile('sonic', 'assets/sprites/sonic_havok_sanity.png');
game.loader.load();
}
var atari1: Phaser.Sprite;
var atari2: Phaser.Sprite;
var sonic: Phaser.Sprite;
function create() {
atari1 = game.add.sprite(100, 100, 'atari1');
atari2 = game.add.sprite(300, 200, 'atari2');
sonic = game.add.sprite(400, 300, 'sonic');
atari1.input.start(0, false, true);
atari2.input.start(1, false, true);
sonic.input.start(2, false, true);
atari1.input.enableDrag();
atari2.input.enableDrag();
sonic.input.enableDrag();
}
function render() {
game.input.renderDebugInfo(32, 32);
}
})();