mirror of
https://github.com/wassname/phaser.git
synced 2026-08-10 12:30:48 +08:00
New Input handler implemented.
This commit is contained in:
@@ -119,6 +119,10 @@
|
||||
<Content Include="input\multitouch.js">
|
||||
<DependentUpon>multitouch.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="input\single touch.ts" />
|
||||
<Content Include="input\single touch.js">
|
||||
<DependentUpon>single touch.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="misc\bootscreen.js">
|
||||
<DependentUpon>bootscreen.ts</DependentUpon>
|
||||
</Content>
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,6 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 460, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 460, init, create, update, render);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('bunny', 'assets/sprites/wabbit.png');
|
||||
myGame.loader.load();
|
||||
@@ -15,12 +15,11 @@
|
||||
minY = 0;
|
||||
maxX = myGame.stage.width - 26;
|
||||
maxY = myGame.stage.height - 37;
|
||||
myGame.input.touch.touchDown.add(addBunnies, this);
|
||||
myGame.input.onDown.add(addBunnies, this);
|
||||
// This will really help on slow Android phones
|
||||
myGame.framerate = 30;
|
||||
// Make sure the camera doesn't clip anything
|
||||
myGame.camera.disableClipping = true;
|
||||
myGame.onRenderCallback = render;
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.font = '20px Arial';
|
||||
addBunnies();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 460, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 320, 460, init, create, update, render);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -26,14 +26,13 @@
|
||||
maxX = myGame.stage.width - 26;
|
||||
maxY = myGame.stage.height - 37;
|
||||
|
||||
myGame.input.touch.touchDown.add(addBunnies, this);
|
||||
myGame.input.onDown.add(addBunnies, this);
|
||||
|
||||
// This will really help on slow Android phones
|
||||
myGame.framerate = 30;
|
||||
// Make sure the camera doesn't clip anything
|
||||
myGame.camera.disableClipping = true;
|
||||
|
||||
myGame.onRenderCallback = render;
|
||||
myGame.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
myGame.stage.context.font = '20px Arial';
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgb(0, 0, 0, 0);
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
|
||||
+627
-388
File diff suppressed because it is too large
Load Diff
@@ -3,10 +3,12 @@
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
var bot2;
|
||||
var car;
|
||||
function create() {
|
||||
// This bot will flip properly when he reaches the edge
|
||||
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
|
||||
@@ -18,6 +20,10 @@
|
||||
bot2.animations.add('run');
|
||||
bot2.animations.play('run', 10, true);
|
||||
bot2.velocity.x = -150;
|
||||
// Flip a static sprite (not an animation)
|
||||
car = myGame.createSprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
car.flipped = true;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
|
||||
@@ -7,12 +7,14 @@
|
||||
function init() {
|
||||
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
var bot2: Phaser.Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -28,6 +30,11 @@
|
||||
bot2.animations.play('run', 10, true);
|
||||
bot2.velocity.x = -150;
|
||||
|
||||
// Flip a static sprite (not an animation)
|
||||
car = myGame.createSprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
car.flipped = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
Reference in New Issue
Block a user