mirror of
https://github.com/wassname/phaser.git
synced 2026-08-09 12:20:34 +08:00
Input priority IDs working properly for drag events.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
})();
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -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);
|
||||
}
|
||||
})();
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user