mirror of
https://github.com/wassname/phaser.git
synced 2026-08-01 12:50:06 +08:00
New Input handler implemented.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update, render);
|
||||
function init() {
|
||||
// This sets a limit on the up-scale
|
||||
myGame.stage.scale.maxWidth = 640;
|
||||
@@ -16,7 +16,6 @@
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
|
||||
}
|
||||
myGame.onRenderCallback = render;
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
(function () {
|
||||
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 240, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
myGame.createSprite(myGame.world.randomX, myGame.world.randomY, 'melon');
|
||||
}
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
@@ -1,16 +1,23 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
function init() {
|
||||
// Tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
||||
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
function create() {
|
||||
myGame.onRenderCallback = render;
|
||||
console.log('dragons 8');
|
||||
myGame.input.onDown.add(test1, this);
|
||||
}
|
||||
function test1() {
|
||||
console.log('down');
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
function render() {
|
||||
myGame.input.pointer1.renderDebug();
|
||||
myGame.input.pointer2.renderDebug();
|
||||
myGame.input.pointer3.renderDebug();
|
||||
myGame.input.pointer4.renderDebug();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -2,29 +2,38 @@
|
||||
|
||||
(function () {
|
||||
|
||||
// Here we create a quite tiny game (320x240 in size)
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
// Tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
||||
myGame.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
myGame.loader.addImageFile('dragonsun', 'assets/pics/cougar_dragonsun.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
console.log('dragons 8');
|
||||
|
||||
myGame.input.onDown.add(test1, this);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
function test1() {
|
||||
console.log('down');
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.input.pointer1.renderDebug();
|
||||
myGame.input.pointer2.renderDebug();
|
||||
myGame.input.pointer3.renderDebug();
|
||||
myGame.input.pointer4.renderDebug();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
function init() {
|
||||
}
|
||||
function create() {
|
||||
// We lock the game to allowing only 1 Pointer active
|
||||
// This means on multi-touch systems it will ignore any extra fingers placed down beyond the first
|
||||
myGame.input.maxPointers = 1;
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
function render() {
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
myGame.input.pointer1.renderDebug(true);
|
||||
myGame.input.pointer2.renderDebug(true);
|
||||
myGame.input.pointer3.renderDebug(true);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// We lock the game to allowing only 1 Pointer active
|
||||
// This means on multi-touch systems it will ignore any extra fingers placed down beyond the first
|
||||
myGame.input.maxPointers = 1;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
myGame.input.renderDebugInfo(16, 16);
|
||||
|
||||
myGame.input.pointer1.renderDebug(true);
|
||||
myGame.input.pointer2.renderDebug(true);
|
||||
myGame.input.pointer3.renderDebug(true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user