mirror of
https://github.com/wassname/phaser.git
synced 2026-08-19 12:30:07 +08:00
Preparing for new release
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
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.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
|
||||
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
|
||||
// then you can use this format:
|
||||
bot.animations.add('run', [
|
||||
'run00',
|
||||
'run01',
|
||||
'run02',
|
||||
'run03',
|
||||
'run04',
|
||||
'run05',
|
||||
'run06',
|
||||
'run07',
|
||||
'run08',
|
||||
'run09',
|
||||
'run10'
|
||||
], 10, true, false);
|
||||
bot.animations.play('run');
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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.load();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = myGame.createSprite(myGame.stage.width, 300, 'bot');
|
||||
|
||||
// If you are using a Texture Atlas and want to specify the frames of an animation by their name rather than frame index
|
||||
// then you can use this format:
|
||||
bot.animations.add('run', ['run00', 'run01', 'run02', 'run03', 'run04', 'run05', 'run06', 'run07', 'run08', 'run09', 'run10'], 10, true, false);
|
||||
|
||||
bot.animations.play('run');
|
||||
|
||||
bot.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addSpriteSheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
//myGame.loader.addSpriteSheet('coin', 'assets/sprites/coin.png', 32, 32);
|
||||
@@ -21,13 +20,13 @@
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Keyboard.LEFT)) {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Keyboard.RIGHT)) {
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.math.velocityFromAngle(car.angle, 200));
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -15,7 +14,7 @@
|
||||
|
||||
}
|
||||
|
||||
var car: Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -37,18 +36,18 @@
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.LEFT))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Keyboard.RIGHT))
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.UP))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.math.velocityFromAngle(car.angle, 200));
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/DynamicTexture.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('ball', 'assets/sprites/shinyball.png');
|
||||
myGame.loader.load();
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/DynamicTexture.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -14,7 +12,7 @@
|
||||
|
||||
}
|
||||
|
||||
var wobblyBall: DynamicTexture;
|
||||
var wobblyBall: Phaser.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('slime', 'assets/sprites/slime.png');
|
||||
myGame.loader.addImageFile('eyes', 'assets/sprites/slimeeyes.png');
|
||||
@@ -31,16 +30,16 @@
|
||||
eyes.velocity.x = 0;
|
||||
eyes.velocity.y = 0;
|
||||
eyes.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Keyboard.LEFT)) {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
slime.angularVelocity = -200;
|
||||
eyes.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Keyboard.RIGHT)) {
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
slime.angularVelocity = 200;
|
||||
eyes.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Keyboard.UP)) {
|
||||
slime.velocity.copyFrom(myGame.math.velocityFromAngle(slime.angle, 200));
|
||||
eyes.velocity.copyFrom(myGame.math.velocityFromAngle(slime.angle, 200));
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
slime.velocity.copyFrom(myGame.motion.velocityFromAngle(slime.angle, 200));
|
||||
eyes.velocity.copyFrom(myGame.motion.velocityFromAngle(slime.angle, 200));
|
||||
}
|
||||
}
|
||||
// This creates a simple sine-wave effect running through our DynamicTexture.
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -14,9 +13,9 @@
|
||||
|
||||
}
|
||||
|
||||
var slime: Sprite;
|
||||
var eyes: Sprite;
|
||||
var wobble: DynamicTexture;
|
||||
var slime: Phaser.Sprite;
|
||||
var eyes: Phaser.Sprite;
|
||||
var wobble: Phaser.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -50,21 +49,21 @@
|
||||
eyes.velocity.y = 0;
|
||||
eyes.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.LEFT))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
slime.angularVelocity = -200;
|
||||
eyes.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Keyboard.RIGHT))
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
slime.angularVelocity = 200;
|
||||
eyes.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.UP))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
slime.velocity.copyFrom(myGame.math.velocityFromAngle(slime.angle, 200));
|
||||
eyes.velocity.copyFrom(myGame.math.velocityFromAngle(slime.angle, 200));
|
||||
slime.velocity.copyFrom(myGame.motion.velocityFromAngle(slime.angle, 200));
|
||||
eyes.velocity.copyFrom(myGame.motion.velocityFromAngle(slime.angle, 200));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Group.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('bunny', 'assets/sprites/wabbit.png');
|
||||
myGame.loader.load();
|
||||
@@ -35,7 +33,7 @@
|
||||
function update() {
|
||||
fps.textContent = 'Press Up to add more\n\nBunnies: ' + myGame.world.group.length + '\nFPS: ' + myGame.time.fps + ' (' + myGame.time.fpsMin + '-' + myGame.time.fpsMax + ')';
|
||||
myGame.world.group.forEach(checkWalls);
|
||||
if(myGame.input.keyboard.isDown(Keyboard.UP)) {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
addBunnies(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Group.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -56,14 +54,14 @@
|
||||
|
||||
myGame.world.group.forEach(checkWalls);
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.UP))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
addBunnies(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkWalls(bunny:Sprite) {
|
||||
function checkWalls(bunny:Phaser.Sprite) {
|
||||
|
||||
if (bunny.x > maxX)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var teddy;
|
||||
function create() {
|
||||
teddy = myGame.createSprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
teddy.origin.setTo(-100, -100);
|
||||
}
|
||||
function update() {
|
||||
teddy.angularVelocity = 0;
|
||||
//car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
teddy.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
teddy.angularVelocity = 200;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,43 @@
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('teddy', 'assets/pics/profil-sad_plush.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var teddy: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
teddy = myGame.createSprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
|
||||
teddy.origin.setTo(-100, -100);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
teddy.angularVelocity = 0;
|
||||
//car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
teddy.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
teddy.angularVelocity = 200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 2
|
||||
//
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -17,7 +16,7 @@
|
||||
|
||||
}
|
||||
|
||||
var bot: Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 3
|
||||
//
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -16,7 +15,7 @@
|
||||
|
||||
}
|
||||
|
||||
var bot: Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Texture Atlas Method 4
|
||||
//
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -16,11 +15,11 @@
|
||||
|
||||
}
|
||||
|
||||
var chick: Sprite;
|
||||
var car: Sprite;
|
||||
var mech: Sprite;
|
||||
var robot: Sprite;
|
||||
var cop: Sprite;
|
||||
var chick: Phaser.Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
var mech: Phaser.Sprite;
|
||||
var robot: Phaser.Sprite;
|
||||
var cop: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -17,7 +16,7 @@
|
||||
|
||||
}
|
||||
|
||||
var bot: Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
(function () {
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/asteroids_ship.png');
|
||||
myGame.loader.load();
|
||||
@@ -16,18 +15,18 @@
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Keyboard.LEFT)) {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Keyboard.RIGHT)) {
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Keyboard.UP)) {
|
||||
var motion = myGame.math.velocityFromAngle(car.angle, 200);
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 200);
|
||||
// instant
|
||||
car.velocity.copyFrom(motion);
|
||||
// acceleration
|
||||
//car.acceleration.copyFrom(motion);
|
||||
} else if(myGame.input.keyboard.isDown(Keyboard.DOWN)) {
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
//car.velocity.y = 200;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/Sprite.ts" />
|
||||
/// <reference path="../../Phaser/Phaser.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Game(this, 'game', 800, 600, init, create, update);
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
@@ -13,7 +12,7 @@
|
||||
|
||||
}
|
||||
|
||||
var car: Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -30,18 +29,18 @@
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.LEFT))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Keyboard.RIGHT))
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Keyboard.UP))
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Point = myGame.math.velocityFromAngle(car.angle, 200);
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 200);
|
||||
|
||||
// instant
|
||||
car.velocity.copyFrom(motion);
|
||||
@@ -49,7 +48,7 @@
|
||||
// acceleration
|
||||
//car.acceleration.copyFrom(motion);
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Keyboard.DOWN))
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
//car.velocity.y = 200;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user