mirror of
https://github.com/wassname/phaser.git
synced 2026-08-16 11:25:21 +08:00
Preparing new tests
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
myGame.input.onDown.add(click, this);
|
||||
teddy.renderDebug = true;
|
||||
}
|
||||
function click() {
|
||||
if(teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT) {
|
||||
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
|
||||
} else {
|
||||
teddy.align++;
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
teddy.x = myGame.input.x;
|
||||
teddy.y = myGame.input.y;
|
||||
}
|
||||
})();
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(0, 0, 'teddy');
|
||||
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
|
||||
myGame.input.onDown.add(click, this);
|
||||
|
||||
teddy.renderDebug = true;
|
||||
|
||||
}
|
||||
|
||||
function click() {
|
||||
|
||||
if (teddy.align == Phaser.GameObject.ALIGN_BOTTOM_RIGHT)
|
||||
{
|
||||
teddy.align = Phaser.GameObject.ALIGN_TOP_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
teddy.align++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
teddy.x = myGame.input.x;
|
||||
teddy.y = myGame.input.y;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,34 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(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,40 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(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,32 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
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);
|
||||
myGame.loader.addSpriteSheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
function create() {
|
||||
car = myGame.add.sprite(200, 300, 'monster');
|
||||
car.animations.add('spin', null, 30, true);
|
||||
//car.animations.play('spin', 30, true);
|
||||
car.animations.play('spin');
|
||||
}
|
||||
function update() {
|
||||
car.renderDebugInfo(16, 16);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,55 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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);
|
||||
myGame.loader.addSpriteSheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
car = myGame.add.sprite(200, 300, 'monster');
|
||||
|
||||
car.animations.add('spin', null, 30, true);
|
||||
|
||||
//car.animations.play('spin', 30, true);
|
||||
car.animations.play('spin');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.renderDebugInfo(16, 16);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
car.velocity.copyFrom(myGame.motion.velocityFromAngle(car.angle, 200));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
}
|
||||
function create() {
|
||||
// This will create a Sprite positioned at the top-left of the game (0,0)
|
||||
// Try changing the 0, 0 values
|
||||
game.add.sprite(0, 0, 'bunny');
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This will create a Sprite positioned at the top-left of the game (0,0)
|
||||
// Try changing the 0, 0 values
|
||||
game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,59 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
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();
|
||||
}
|
||||
var wobblyBall;
|
||||
function create() {
|
||||
// Create our DynamicTexture
|
||||
wobblyBall = myGame.add.dynamicTexture(32, 64);
|
||||
// And apply it to 100 randomly positioned sprites
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var temp = myGame.add.sprite(myGame.world.randomX, myGame.world.randomY);
|
||||
temp.width = 32;
|
||||
temp.height = 64;
|
||||
temp.loadDynamicTexture(wobblyBall);
|
||||
}
|
||||
// Populate the wave with some data
|
||||
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
|
||||
}
|
||||
function update() {
|
||||
wobblyBall.clear();
|
||||
updateWobblyBall();
|
||||
}
|
||||
// This creates a simple sine-wave effect running through our DynamicTexture.
|
||||
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
|
||||
var waveSize = 8;
|
||||
var wavePixelChunk = 2;
|
||||
var waveData;
|
||||
var waveDataCounter;
|
||||
function updateWobblyBall() {
|
||||
var s = 0;
|
||||
var copyRect = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: wavePixelChunk,
|
||||
h: 32
|
||||
};
|
||||
var copyPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
for(var x = 0; x < 32; x += wavePixelChunk) {
|
||||
copyPoint.x = x;
|
||||
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
|
||||
wobblyBall.context.drawImage(myGame.cache.getImage('ball'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
|
||||
copyRect.x += wavePixelChunk;
|
||||
s++;
|
||||
}
|
||||
// Cycle through the wave data - this is what causes the image to "undulate"
|
||||
var t = waveData.shift();
|
||||
waveData.push(t);
|
||||
waveDataCounter++;
|
||||
if(waveDataCounter == waveData.length) {
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,82 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
var wobblyBall: Phaser.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
// Create our DynamicTexture
|
||||
wobblyBall = myGame.add.dynamicTexture(32, 64);
|
||||
|
||||
// And apply it to 100 randomly positioned sprites
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var temp = myGame.add.sprite(myGame.world.randomX, myGame.world.randomY);
|
||||
temp.width = 32;
|
||||
temp.height = 64;
|
||||
temp.loadDynamicTexture(wobblyBall);
|
||||
}
|
||||
|
||||
// Populate the wave with some data
|
||||
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
wobblyBall.clear();
|
||||
|
||||
updateWobblyBall();
|
||||
|
||||
}
|
||||
|
||||
// This creates a simple sine-wave effect running through our DynamicTexture.
|
||||
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
|
||||
|
||||
var waveSize = 8;
|
||||
var wavePixelChunk = 2;
|
||||
var waveData;
|
||||
var waveDataCounter;
|
||||
|
||||
function updateWobblyBall()
|
||||
{
|
||||
var s = 0;
|
||||
var copyRect = { x: 0, y: 0, w: wavePixelChunk, h: 32 };
|
||||
var copyPoint = { x: 0, y: 0 };
|
||||
|
||||
for (var x = 0; x < 32; x += wavePixelChunk)
|
||||
{
|
||||
copyPoint.x = x;
|
||||
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
|
||||
|
||||
wobblyBall.context.drawImage(myGame.cache.getImage('ball'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
|
||||
|
||||
copyRect.x += wavePixelChunk;
|
||||
|
||||
s++;
|
||||
}
|
||||
|
||||
// Cycle through the wave data - this is what causes the image to "undulate"
|
||||
var t = waveData.shift();
|
||||
waveData.push(t);
|
||||
|
||||
waveDataCounter++;
|
||||
|
||||
if (waveDataCounter == waveData.length)
|
||||
{
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,78 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
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');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var slime;
|
||||
var eyes;
|
||||
var wobble;
|
||||
function create() {
|
||||
myGame.camera.backgroundColor = 'rgb(82,154,206)';
|
||||
// Create our DynamicTexture
|
||||
wobble = myGame.add.dynamicTexture(48, 100);
|
||||
slime = myGame.add.sprite(200, 300);
|
||||
slime.width = 48;
|
||||
slime.height = 100;
|
||||
slime.loadDynamicTexture(wobble);
|
||||
eyes = myGame.add.sprite(210, 326, 'eyes');
|
||||
// Populate the wave with some data
|
||||
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
|
||||
}
|
||||
function update() {
|
||||
wobble.clear();
|
||||
updateWobble();
|
||||
slime.velocity.x = 0;
|
||||
slime.velocity.y = 0;
|
||||
slime.angularVelocity = 0;
|
||||
eyes.velocity.x = 0;
|
||||
eyes.velocity.y = 0;
|
||||
eyes.angularVelocity = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
slime.angularVelocity = -200;
|
||||
eyes.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
slime.angularVelocity = 200;
|
||||
eyes.angularVelocity = 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.
|
||||
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
|
||||
var waveSize = 8;
|
||||
var wavePixelChunk = 2;
|
||||
var waveData;
|
||||
var waveDataCounter;
|
||||
function updateWobble() {
|
||||
var s = 0;
|
||||
var copyRect = {
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: wavePixelChunk,
|
||||
h: 52
|
||||
};
|
||||
var copyPoint = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
for(var x = 0; x < 48; x += wavePixelChunk) {
|
||||
copyPoint.x = x;
|
||||
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
|
||||
wobble.context.drawImage(myGame.cache.getImage('slime'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
|
||||
copyRect.x += wavePixelChunk;
|
||||
s++;
|
||||
}
|
||||
// Cycle through the wave data - this is what causes the image to "undulate"
|
||||
var t = waveData.shift();
|
||||
waveData.push(t);
|
||||
waveDataCounter++;
|
||||
if(waveDataCounter == waveData.length) {
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,109 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var slime: Phaser.Sprite;
|
||||
var eyes: Phaser.Sprite;
|
||||
var wobble: Phaser.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.camera.backgroundColor = 'rgb(82,154,206)';
|
||||
|
||||
// Create our DynamicTexture
|
||||
wobble = myGame.add.dynamicTexture(48, 100);
|
||||
|
||||
slime = myGame.add.sprite(200, 300);
|
||||
slime.width = 48;
|
||||
slime.height = 100;
|
||||
slime.loadDynamicTexture(wobble);
|
||||
|
||||
eyes = myGame.add.sprite(210, 326, 'eyes');
|
||||
|
||||
// Populate the wave with some data
|
||||
waveData = myGame.math.sinCosGenerator(32, 8, 8, 2);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
wobble.clear();
|
||||
|
||||
updateWobble();
|
||||
|
||||
slime.velocity.x = 0;
|
||||
slime.velocity.y = 0;
|
||||
slime.angularVelocity = 0;
|
||||
eyes.velocity.x = 0;
|
||||
eyes.velocity.y = 0;
|
||||
eyes.angularVelocity = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
slime.angularVelocity = -200;
|
||||
eyes.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
slime.angularVelocity = 200;
|
||||
eyes.angularVelocity = 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.
|
||||
// This is then duplicated across all sprites using it, meaning we only have to calculate it once.
|
||||
|
||||
var waveSize = 8;
|
||||
var wavePixelChunk = 2;
|
||||
var waveData;
|
||||
var waveDataCounter;
|
||||
|
||||
function updateWobble()
|
||||
{
|
||||
var s = 0;
|
||||
var copyRect = { x: 0, y: 0, w: wavePixelChunk, h: 52 };
|
||||
var copyPoint = { x: 0, y: 0 };
|
||||
|
||||
for (var x = 0; x < 48; x += wavePixelChunk)
|
||||
{
|
||||
copyPoint.x = x;
|
||||
copyPoint.y = waveSize + (waveSize / 2) + waveData[s];
|
||||
|
||||
wobble.context.drawImage(myGame.cache.getImage('slime'), copyRect.x, copyRect.y, copyRect.w, copyRect.h, copyPoint.x, copyPoint.y, copyRect.w, copyRect.h);
|
||||
|
||||
copyRect.x += wavePixelChunk;
|
||||
|
||||
s++;
|
||||
}
|
||||
|
||||
// Cycle through the wave data - this is what causes the image to "undulate"
|
||||
var t = waveData.shift();
|
||||
waveData.push(t);
|
||||
|
||||
waveDataCounter++;
|
||||
|
||||
if (waveDataCounter == waveData.length)
|
||||
{
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,42 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.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.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -200;
|
||||
// This one won't
|
||||
bot2 = myGame.add.sprite(myGame.stage.width, 200, 'bot');
|
||||
bot2.animations.add('run');
|
||||
bot2.animations.play('run', 10, true);
|
||||
bot2.velocity.x = -150;
|
||||
// Flip a static sprite (not an animation)
|
||||
car = myGame.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
car.flipped = true;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.flipped = true;
|
||||
bot.velocity.x = 200;
|
||||
} else if(bot.x > myGame.stage.width) {
|
||||
bot.flipped = false;
|
||||
bot.velocity.x = -200;
|
||||
}
|
||||
if(bot2.x < -bot2.width) {
|
||||
bot2.velocity.x = 200;
|
||||
} else if(bot2.x > myGame.stage.width) {
|
||||
bot2.velocity.x = -200;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,64 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.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() {
|
||||
|
||||
// This bot will flip properly when he reaches the edge
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -200;
|
||||
|
||||
// This one won't
|
||||
bot2 = myGame.add.sprite(myGame.stage.width, 200, 'bot');
|
||||
bot2.animations.add('run');
|
||||
bot2.animations.play('run', 10, true);
|
||||
bot2.velocity.x = -150;
|
||||
|
||||
// Flip a static sprite (not an animation)
|
||||
car = myGame.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
car.flipped = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.flipped = true;
|
||||
bot.velocity.x = 200;
|
||||
}
|
||||
else if (bot.x > myGame.stage.width)
|
||||
{
|
||||
bot.flipped = false;
|
||||
bot.velocity.x = -200;
|
||||
}
|
||||
|
||||
if (bot2.x < -bot2.width)
|
||||
{
|
||||
bot2.velocity.x = 200;
|
||||
}
|
||||
else if (bot2.x > myGame.stage.width)
|
||||
{
|
||||
bot2.velocity.x = -200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,56 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
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();
|
||||
}
|
||||
var maxX;
|
||||
var maxY;
|
||||
var minX;
|
||||
var minY;
|
||||
var fps;
|
||||
function create() {
|
||||
// FPS counter TextArea
|
||||
fps = document.createElement('textarea');
|
||||
fps.style.width = '300px';
|
||||
fps.style.height = '100px';
|
||||
document.getElementById('game').appendChild(fps);
|
||||
minX = 0;
|
||||
minY = 0;
|
||||
maxX = myGame.stage.width - 26;
|
||||
maxY = myGame.stage.height - 37;
|
||||
addBunnies(500);
|
||||
}
|
||||
function addBunnies(quantity) {
|
||||
for(var i = 0; i < quantity; i++) {
|
||||
var tempSprite = myGame.add.sprite(myGame.stage.randomX, 0, 'bunny');
|
||||
tempSprite.velocity.x = -200 + (Math.random() * 400);
|
||||
tempSprite.velocity.y = 100 + Math.random() * 200;
|
||||
}
|
||||
}
|
||||
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(Phaser.Keyboard.UP)) {
|
||||
addBunnies(10);
|
||||
}
|
||||
}
|
||||
function checkWalls(bunny) {
|
||||
if(bunny.x > maxX) {
|
||||
bunny.velocity.x *= -1;
|
||||
bunny.x = maxX;
|
||||
} else if(bunny.x < minX) {
|
||||
bunny.velocity.x *= -1;
|
||||
bunny.x = minX;
|
||||
}
|
||||
if(bunny.y > maxY) {
|
||||
bunny.velocity.y *= -0.8;
|
||||
bunny.y = maxY;
|
||||
} else if(bunny.y < minY) {
|
||||
bunny.velocity.x = -200 + (Math.random() * 400);
|
||||
bunny.velocity.y = 100 + Math.random() * 200;
|
||||
bunny.y = minY;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,89 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
var maxX: number;
|
||||
var maxY: number;
|
||||
var minX: number;
|
||||
var minY: number;
|
||||
var fps: HTMLTextAreaElement;
|
||||
|
||||
function create() {
|
||||
|
||||
// FPS counter TextArea
|
||||
fps = <HTMLTextAreaElement> document.createElement('textarea');
|
||||
fps.style.width = '300px';
|
||||
fps.style.height = '100px';
|
||||
document.getElementById('game').appendChild(fps);
|
||||
|
||||
minX = 0;
|
||||
minY = 0;
|
||||
maxX = myGame.stage.width - 26;
|
||||
maxY = myGame.stage.height - 37;
|
||||
|
||||
addBunnies(500);
|
||||
|
||||
}
|
||||
|
||||
function addBunnies(quantity) {
|
||||
|
||||
for (var i = 0; i < quantity; i++)
|
||||
{
|
||||
var tempSprite = myGame.add.sprite(myGame.stage.randomX, 0, 'bunny');
|
||||
tempSprite.velocity.x = -200 + (Math.random() * 400);
|
||||
tempSprite.velocity.y = 100 + Math.random() * 200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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(Phaser.Keyboard.UP))
|
||||
{
|
||||
addBunnies(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function checkWalls(bunny:Phaser.Sprite) {
|
||||
|
||||
if (bunny.x > maxX)
|
||||
{
|
||||
bunny.velocity.x *= -1;
|
||||
bunny.x = maxX;
|
||||
}
|
||||
else if (bunny.x < minX)
|
||||
{
|
||||
bunny.velocity.x *= -1;
|
||||
bunny.x = minX;
|
||||
}
|
||||
|
||||
if (bunny.y > maxY)
|
||||
{
|
||||
bunny.velocity.y *= -0.8;
|
||||
bunny.y = maxY;
|
||||
}
|
||||
else if (bunny.y < minY)
|
||||
{
|
||||
bunny.velocity.x = -200 + (Math.random() * 400);
|
||||
bunny.velocity.y = 100 + Math.random() * 200;
|
||||
bunny.y = minY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,22 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
teddy.renderDebug = true;
|
||||
}
|
||||
function update() {
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
teddy.angularAcceleration = -40;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
teddy.angularAcceleration = 40;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,39 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.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.add.sprite(0, 0, 'teddy');
|
||||
teddy.x = myGame.stage.centerX - teddy.width / 2;
|
||||
teddy.y = myGame.stage.centerY - teddy.height / 2;
|
||||
teddy.renderDebug = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
teddy.angularAcceleration = -40;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
teddy.angularAcceleration = 40;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,58 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var fuji;
|
||||
var tween;
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,100)';
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
fuji = game.add.sprite(100, 200, 'fuji');
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
//fuji.origin.setTo(160, 0);
|
||||
fuji.origin.setTo(160, 100);
|
||||
//fuji.origin.setTo(320, 0);
|
||||
//fuji.origin.setTo(320, 200);
|
||||
//fuji.origin.setTo(260, 100);
|
||||
fuji.scale.x = 2;
|
||||
fuji.scale.y = 0.5;
|
||||
//fuji.position.rotation = 45;
|
||||
game.add.tween(fuji.position).to({
|
||||
rotation: 360
|
||||
}, 3000).start();
|
||||
// Create our tween
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
// Start it going
|
||||
//scaleLeft();
|
||||
}
|
||||
function rotate() {
|
||||
tween.to({
|
||||
x: 0
|
||||
}, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
}
|
||||
function scaleLeft() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 0
|
||||
}, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
}
|
||||
function scaleRight() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 1
|
||||
}, 1000);
|
||||
tween.onComplete.add(scaleLeft, this);
|
||||
tween.start();
|
||||
// This line says "if the texture is flippedX then unflip it (set flippedX to false), otherwise set flippedX to true
|
||||
(fuji.texture.flippedX) ? fuji.texture.flippedX = false : fuji.texture.flippedX = true;
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,75 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var fuji: Phaser.Sprite;
|
||||
var tween: Phaser.Tween;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = 'rgb(0,0,100)';
|
||||
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
fuji = game.add.sprite(100, 200, 'fuji');
|
||||
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
//fuji.origin.setTo(160, 0);
|
||||
fuji.origin.setTo(160, 100);
|
||||
//fuji.origin.setTo(320, 0);
|
||||
//fuji.origin.setTo(320, 200);
|
||||
|
||||
//fuji.origin.setTo(260, 100);
|
||||
fuji.scale.x = 2;
|
||||
fuji.scale.y = 0.5;
|
||||
//fuji.position.rotation = 45;
|
||||
game.add.tween(fuji.position).to({ rotation: 360 }, 3000).start();
|
||||
|
||||
// Create our tween
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
|
||||
// Start it going
|
||||
//scaleLeft();
|
||||
|
||||
}
|
||||
|
||||
function rotate() {
|
||||
|
||||
tween.to({ x: 0 }, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
|
||||
}
|
||||
|
||||
function scaleLeft() {
|
||||
|
||||
tween.clear();
|
||||
tween.to({ x: 0 }, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
|
||||
}
|
||||
|
||||
function scaleRight() {
|
||||
|
||||
tween.clear();
|
||||
tween.to({ x: 1 }, 1000);
|
||||
tween.onComplete.add(scaleLeft, this);
|
||||
tween.start();
|
||||
|
||||
// This line says "if the texture is flippedX then unflip it (set flippedX to false), otherwise set flippedX to true
|
||||
(fuji.texture.flippedX) ? fuji.texture.flippedX = false: fuji.texture.flippedX = true;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var smallBunny;
|
||||
function create() {
|
||||
// Here we'll assign the new sprite to the local smallBunny variable
|
||||
smallBunny = game.add.sprite(0, 0, 'bunny');
|
||||
// And now let's scale the sprite in half
|
||||
// You can do either:
|
||||
// smallBunny.scale.x = 0.5;
|
||||
// smallBunny.scale.y = 0.5;
|
||||
// Or you can set them both at the same time using setTo:
|
||||
smallBunny.scale.setTo(0.5, 0.5);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var smallBunny: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll assign the new sprite to the local smallBunny variable
|
||||
smallBunny = game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
// And now let's scale the sprite in half
|
||||
|
||||
// You can do either:
|
||||
// smallBunny.scale.x = 0.5;
|
||||
// smallBunny.scale.y = 0.5;
|
||||
|
||||
// Or you can set them both at the same time using setTo:
|
||||
smallBunny.scale.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var bigBunny;
|
||||
function create() {
|
||||
// Here we'll assign the new sprite to the local bigBunny variable
|
||||
bigBunny = game.add.sprite(0, 0, 'bunny');
|
||||
// And now let's scale the sprite by two
|
||||
// You can do either:
|
||||
// smallBunny.scale.x = 2;
|
||||
// smallBunny.scale.y = 2;
|
||||
// Or you can set them both at the same time using setTo:
|
||||
bigBunny.scale.setTo(2, 2);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bigBunny: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll assign the new sprite to the local bigBunny variable
|
||||
bigBunny = game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
// And now let's scale the sprite by two
|
||||
|
||||
// You can do either:
|
||||
// smallBunny.scale.x = 2;
|
||||
// smallBunny.scale.y = 2;
|
||||
|
||||
// Or you can set them both at the same time using setTo:
|
||||
bigBunny.scale.setTo(2, 2);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,17 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var bunny;
|
||||
function create() {
|
||||
// Here we'll assign the new sprite to the local bunny variable
|
||||
bunny = game.add.sprite(0, 0, 'bunny');
|
||||
// You don't have to use the same values when scaling a sprite,
|
||||
// here we'll create a short and wide bunny
|
||||
bunny.scale.setTo(3, 0.7);
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,29 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bunny: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll assign the new sprite to the local bunny variable
|
||||
bunny = game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
// You don't have to use the same values when scaling a sprite,
|
||||
// here we'll create a short and wide bunny
|
||||
|
||||
bunny.scale.setTo(3, 0.7);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var bunny;
|
||||
var tweenUp;
|
||||
var tweenDown;
|
||||
function create() {
|
||||
// Here we'll assign the new sprite to the local bunny variable
|
||||
bunny = game.add.sprite(0, 0, 'bunny');
|
||||
// This time let's scale the sprite by using two tweens
|
||||
// The first tween will scale the sprite up, the second will scale it down again
|
||||
// Create our 2 tweens
|
||||
tweenUp = game.add.tween(bunny.scale);
|
||||
tweenUp.onComplete.add(scaleDown, this);
|
||||
tweenDown = game.add.tween(bunny.scale);
|
||||
tweenDown.onComplete.add(scaleUp, this);
|
||||
// Start it going
|
||||
scaleUp();
|
||||
}
|
||||
function scaleUp() {
|
||||
tweenUp.to({
|
||||
x: 2,
|
||||
y: 2
|
||||
}, 2000, Phaser.Easing.Elastic.Out);
|
||||
tweenUp.start();
|
||||
}
|
||||
function scaleDown() {
|
||||
tweenDown.to({
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
}, 2000, Phaser.Easing.Elastic.Out);
|
||||
tweenDown.start();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,53 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('bunny', 'assets/sprites/bunny.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bunny: Phaser.Sprite;
|
||||
var tweenUp: Phaser.Tween;
|
||||
var tweenDown: Phaser.Tween;
|
||||
|
||||
function create() {
|
||||
|
||||
// Here we'll assign the new sprite to the local bunny variable
|
||||
bunny = game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
// This time let's scale the sprite by using two tweens
|
||||
// The first tween will scale the sprite up, the second will scale it down again
|
||||
|
||||
// Create our 2 tweens
|
||||
tweenUp = game.add.tween(bunny.scale);
|
||||
tweenUp.onComplete.add(scaleDown, this);
|
||||
|
||||
tweenDown = game.add.tween(bunny.scale);
|
||||
tweenDown.onComplete.add(scaleUp, this);
|
||||
|
||||
// Start it going
|
||||
scaleUp();
|
||||
|
||||
}
|
||||
|
||||
function scaleUp() {
|
||||
|
||||
tweenUp.to({ x: 2, y: 2 }, 2000, Phaser.Easing.Elastic.Out);
|
||||
tweenUp.start();
|
||||
|
||||
}
|
||||
|
||||
function scaleDown() {
|
||||
|
||||
tweenDown.to({ x: 0.5, y: 0.5 }, 2000, Phaser.Easing.Elastic.Out);
|
||||
tweenDown.start();
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,52 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
game.loader.load();
|
||||
}
|
||||
var fuji;
|
||||
var tween;
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,100)';
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
//fuji = game.add.sprite(game.stage.centerX - 160, game.stage.centerY - 100, 'fuji');
|
||||
fuji = game.add.sprite(100, game.stage.centerY - 100, 'fuji');
|
||||
//fuji.scale.x = 2;
|
||||
//fuji.scale.y = 2;
|
||||
//fuji.texture.flippedX = true;
|
||||
fuji.texture.flippedY = true;
|
||||
//fuji.origin.setTo(160, 100);
|
||||
//fuji.rotation = 45;
|
||||
game.add.tween(fuji.position).to({
|
||||
rotation: 360
|
||||
}, 3000).start();
|
||||
// We set the origin of the Sprite to be the center so that the scaling happens around the center, not the left-hand side
|
||||
//fuji.origin.setTo(160, 100);
|
||||
// We'll tween the scale down to zero (which will make the sprite invisible) and then flip it
|
||||
// The end result should look like turning over a card
|
||||
// Create our tween
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
// Start it going
|
||||
//scaleLeft();
|
||||
}
|
||||
function scaleLeft() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 0
|
||||
}, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
}
|
||||
function scaleRight() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 1
|
||||
}, 1000);
|
||||
tween.onComplete.add(scaleLeft, this);
|
||||
tween.start();
|
||||
// This line says "if the texture is flippedX then unflip it (set flippedX to false), otherwise set flippedX to true
|
||||
(fuji.texture.flippedX) ? fuji.texture.flippedX = false : fuji.texture.flippedX = true;
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,71 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.loader.addImageFile('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
game.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var fuji: Phaser.Sprite;
|
||||
var tween: Phaser.Tween;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = 'rgb(0,0,100)';
|
||||
|
||||
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
//fuji = game.add.sprite(game.stage.centerX - 160, game.stage.centerY - 100, 'fuji');
|
||||
fuji = game.add.sprite(100, game.stage.centerY - 100, 'fuji');
|
||||
|
||||
//fuji.scale.x = 2;
|
||||
//fuji.scale.y = 2;
|
||||
//fuji.texture.flippedX = true;
|
||||
fuji.texture.flippedY = true;
|
||||
|
||||
//fuji.origin.setTo(160, 100);
|
||||
//fuji.rotation = 45;
|
||||
game.add.tween(fuji.position).to({ rotation: 360 }, 3000).start();
|
||||
|
||||
// We set the origin of the Sprite to be the center so that the scaling happens around the center, not the left-hand side
|
||||
//fuji.origin.setTo(160, 100);
|
||||
|
||||
// We'll tween the scale down to zero (which will make the sprite invisible) and then flip it
|
||||
// The end result should look like turning over a card
|
||||
|
||||
// Create our tween
|
||||
//tween = game.add.tween(fuji.scale);
|
||||
|
||||
// Start it going
|
||||
//scaleLeft();
|
||||
|
||||
}
|
||||
|
||||
function scaleLeft() {
|
||||
|
||||
tween.clear();
|
||||
tween.to({ x: 0 }, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
|
||||
}
|
||||
|
||||
function scaleRight() {
|
||||
|
||||
tween.clear();
|
||||
tween.to({ x: 1 }, 1000);
|
||||
tween.onComplete.add(scaleLeft, this);
|
||||
tween.start();
|
||||
|
||||
// This line says "if the texture is flippedX then unflip it (set flippedX to false), otherwise set flippedX to true
|
||||
(fuji.texture.flippedX) ? fuji.texture.flippedX = false: fuji.texture.flippedX = true;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,32 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Starling/Sparrow XML Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the XML data is stored in an external file
|
||||
myGame.loader.addTextureAtlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bits;
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.add.sprite(800, 200, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bits = myGame.add.sprite(200, 200, 'bits');
|
||||
bits.frame = 0;
|
||||
bot.velocity.x = -300;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
bits.frame++;
|
||||
console.log(bits.frame, bits.animations.frameTotal);
|
||||
if(bits.frame == bits.animations.frameTotal - 1) {
|
||||
bits.frame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,52 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// Starling/Sparrow XML Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the XML data is stored in an external file
|
||||
myGame.loader.addTextureAtlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bits: Phaser.Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = myGame.add.sprite(800, 200, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
bits = myGame.add.sprite(200, 200, 'bits');
|
||||
bits.frame = 0;
|
||||
|
||||
bot.velocity.x = -300;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
|
||||
bits.frame++;
|
||||
console.log(bits.frame, bits.animations.frameTotal);
|
||||
|
||||
if (bits.frame == bits.animations.frameTotal - 1)
|
||||
{
|
||||
bits.frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,25 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 2
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
|
||||
// (in this case botData)
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
var botData = '{"frames": [{"filename": "running bot.swf/0000","frame": { "x": 34, "y": 128, "w": 56, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0001","frame": { "x": 54, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0002","frame": { "x": 54, "y": 58, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0003","frame": { "x": 0, "y": 192, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0004","frame": { "x": 0, "y": 64, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0005","frame": { "x": 196, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0006","frame": { "x": 0, "y": 0, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0007","frame": { "x": 140, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0008","frame": { "x": 34, "y": 188, "w": 50, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0009","frame": { "x": 0, "y": 128, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0010","frame": { "x": 84, "y": 188, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }}]}';
|
||||
})();
|
||||
@@ -1,43 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// Texture Atlas Method 2
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
|
||||
// (in this case botData)
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
bot.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var botData = '{"frames": [{"filename": "running bot.swf/0000","frame": { "x": 34, "y": 128, "w": 56, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0001","frame": { "x": 54, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0002","frame": { "x": 54, "y": 58, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0003","frame": { "x": 0, "y": 192, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0004","frame": { "x": 0, "y": 64, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0005","frame": { "x": 196, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0006","frame": { "x": 0, "y": 0, "w": 54, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0007","frame": { "x": 140, "y": 0, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0008","frame": { "x": 34, "y": 188, "w": 50, "h": 60 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0009","frame": { "x": 0, "y": 128, "w": 34, "h": 64 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },"sourceSize": { "w": 56, "h": 64 }},{"filename": "running bot.swf/0010","frame": { "x": 84, "y": 188, "w": 56, "h": 58 },"rotated": false,"trimmed": true,"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },"sourceSize": { "w": 56, "h": 64 }}]}';
|
||||
|
||||
})();
|
||||
@@ -1,23 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 3
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is stored in an external file
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,40 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// Texture Atlas Method 3
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is stored in an external file
|
||||
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.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
bot.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,32 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Texture Atlas Method 4
|
||||
//
|
||||
// We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file
|
||||
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var chick;
|
||||
var car;
|
||||
var mech;
|
||||
var robot;
|
||||
var cop;
|
||||
function create() {
|
||||
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
|
||||
chick = myGame.add.sprite(64, 64, 'atlas');
|
||||
// You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself)
|
||||
chick.frameName = 'budbrain_chick.png';
|
||||
// Or by setting the frame index
|
||||
//chick.frame = 0;
|
||||
cop = myGame.add.sprite(600, 64, 'atlas');
|
||||
cop.frameName = 'ladycop.png';
|
||||
robot = myGame.add.sprite(50, 300, 'atlas');
|
||||
robot.frameName = 'robot.png';
|
||||
car = myGame.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
mech = myGame.add.sprite(250, 100, 'atlas');
|
||||
mech.frameName = 'titan_mech.png';
|
||||
}
|
||||
})();
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Texture Atlas Method 4
|
||||
//
|
||||
// We load a TexturePacker JSON file and image and show you how to make several unique sprites from the same file
|
||||
myGame.loader.addTextureAtlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var chick: Phaser.Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
var mech: Phaser.Sprite;
|
||||
var robot: Phaser.Sprite;
|
||||
var cop: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.camera.backgroundColor = 'rgb(40, 40, 40)';
|
||||
|
||||
chick = myGame.add.sprite(64, 64, 'atlas');
|
||||
|
||||
// You can set the frame based on the frame name (which TexturePacker usually sets to be the filename of the image itself)
|
||||
chick.frameName = 'budbrain_chick.png';
|
||||
|
||||
// Or by setting the frame index
|
||||
//chick.frame = 0;
|
||||
|
||||
cop = myGame.add.sprite(600, 64, 'atlas');
|
||||
cop.frameName = 'ladycop.png';
|
||||
|
||||
robot = myGame.add.sprite(50, 300, 'atlas');
|
||||
robot.frameName = 'robot.png';
|
||||
|
||||
car = myGame.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
|
||||
mech = myGame.add.sprite(250, 100, 'atlas');
|
||||
mech.frameName = 'titan_mech.png';
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,271 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
|
||||
// (in this case botData)
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
myGame.loader.load();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
bot.velocity.x = -100;
|
||||
}
|
||||
function update() {
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
}
|
||||
var botData = {
|
||||
"frames": [
|
||||
{
|
||||
"filename": "running bot.swf/0000",
|
||||
"frame": {
|
||||
"x": 34,
|
||||
"y": 128,
|
||||
"w": 56,
|
||||
"h": 60
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 2,
|
||||
"w": 56,
|
||||
"h": 60
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0001",
|
||||
"frame": {
|
||||
"x": 54,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0002",
|
||||
"frame": {
|
||||
"x": 54,
|
||||
"y": 58,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0003",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 192,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 11,
|
||||
"y": 0,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0004",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 64,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 1,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0005",
|
||||
"frame": {
|
||||
"x": 196,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0006",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 1,
|
||||
"y": 0,
|
||||
"w": 54,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0007",
|
||||
"frame": {
|
||||
"x": 140,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0008",
|
||||
"frame": {
|
||||
"x": 34,
|
||||
"y": 188,
|
||||
"w": 50,
|
||||
"h": 60
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 3,
|
||||
"y": 2,
|
||||
"w": 50,
|
||||
"h": 60
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0009",
|
||||
"frame": {
|
||||
"x": 0,
|
||||
"y": 128,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 11,
|
||||
"y": 0,
|
||||
"w": 34,
|
||||
"h": 64
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0010",
|
||||
"frame": {
|
||||
"x": 84,
|
||||
"y": 188,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": {
|
||||
"x": 0,
|
||||
"y": 3,
|
||||
"w": 56,
|
||||
"h": 58
|
||||
},
|
||||
"sourceSize": {
|
||||
"w": 56,
|
||||
"h": 64
|
||||
}
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"app": "http://www.texturepacker.com",
|
||||
"version": "1.0",
|
||||
"image": "running_bot.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 252,
|
||||
"h": 256
|
||||
},
|
||||
"scale": "0.2",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -1,143 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a real json object stored as a var
|
||||
// (in this case botData)
|
||||
myGame.loader.addTextureAtlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = myGame.add.sprite(myGame.stage.width, 300, 'bot');
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
bot.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = myGame.stage.width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var botData = {
|
||||
"frames": [
|
||||
|
||||
{
|
||||
"filename": "running bot.swf/0000",
|
||||
"frame": { "x": 34, "y": 128, "w": 56, "h": 60 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 2, "w": 56, "h": 60 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0001",
|
||||
"frame": { "x": 54, "y": 0, "w": 56, "h": 58 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0002",
|
||||
"frame": { "x": 54, "y": 58, "w": 56, "h": 58 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0003",
|
||||
"frame": { "x": 0, "y": 192, "w": 34, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0004",
|
||||
"frame": { "x": 0, "y": 64, "w": 54, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0005",
|
||||
"frame": { "x": 196, "y": 0, "w": 56, "h": 58 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0006",
|
||||
"frame": { "x": 0, "y": 0, "w": 54, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 1, "y": 0, "w": 54, "h": 64 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0007",
|
||||
"frame": { "x": 140, "y": 0, "w": 56, "h": 58 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0008",
|
||||
"frame": { "x": 34, "y": 188, "w": 50, "h": 60 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 3, "y": 2, "w": 50, "h": 60 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0009",
|
||||
"frame": { "x": 0, "y": 128, "w": 34, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 11, "y": 0, "w": 34, "h": 64 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
},
|
||||
{
|
||||
"filename": "running bot.swf/0010",
|
||||
"frame": { "x": 84, "y": 188, "w": 56, "h": 58 },
|
||||
"rotated": false,
|
||||
"trimmed": true,
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
}],
|
||||
"meta": {
|
||||
"app": "http://www.texturepacker.com",
|
||||
"version": "1.0",
|
||||
"image": "running_bot.png",
|
||||
"format": "RGBA8888",
|
||||
"size": { "w": 252, "h": 256 },
|
||||
"scale": "0.2",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -1,33 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
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();
|
||||
}
|
||||
var car;
|
||||
function create() {
|
||||
car = myGame.add.sprite(200, 300, 'car');
|
||||
}
|
||||
function update() {
|
||||
car.renderDebugInfo(16, 16);
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 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(Phaser.Keyboard.DOWN)) {
|
||||
//car.velocity.y = 200;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,58 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
car = myGame.add.sprite(200, 300, 'car');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.renderDebugInfo(16, 16);
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 200);
|
||||
|
||||
// instant
|
||||
car.velocity.copyFrom(motion);
|
||||
|
||||
// acceleration
|
||||
//car.acceleration.copyFrom(motion);
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
//car.velocity.y = 200;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user