mirror of
https://github.com/wassname/phaser.git
synced 2026-07-17 11:31:30 +08:00
Updating and fixing tests
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
game.load.start();
|
||||
}
|
||||
var wobblyBall;
|
||||
function create() {
|
||||
// Create our DynamicTexture
|
||||
wobblyBall = game.add.dynamicTexture(32, 64);
|
||||
// And apply it to 100 randomly positioned sprites
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
|
||||
temp.texture.loadDynamicTexture(wobblyBall);
|
||||
}
|
||||
// Populate the wave with some data
|
||||
waveData = game.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(game.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;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,80 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var wobblyBall: Phaser.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
// Create our DynamicTexture
|
||||
wobblyBall = game.add.dynamicTexture(32, 64);
|
||||
|
||||
// And apply it to 100 randomly positioned sprites
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var temp = game.add.sprite(game.world.randomX, game.world.randomY);
|
||||
temp.texture.loadDynamicTexture(wobblyBall);
|
||||
}
|
||||
|
||||
// Populate the wave with some data
|
||||
waveData = game.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(game.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;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,42 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
var starfield;
|
||||
var xx = [];
|
||||
var yy = [];
|
||||
var zz = [];
|
||||
var xxx = 0;
|
||||
var yyy = 0;
|
||||
function create() {
|
||||
// The width of the starfield
|
||||
var star_w = 12000;
|
||||
for(var i = 0; i < 800; i++) {
|
||||
xx[i] = Math.floor(Math.random() * star_w * 2) - star_w;
|
||||
yy[i] = Math.floor(Math.random() * star_w * 2) - star_w;
|
||||
zz[i] = Math.floor(Math.random() * 160) + 1;
|
||||
}
|
||||
starfield = game.add.dynamicTexture(800, 600);
|
||||
}
|
||||
function update() {
|
||||
starfield.clear();
|
||||
for(var i = 0; i < 800; i++) {
|
||||
if(zz[i] == 1) {
|
||||
zz[i] = 100;
|
||||
}
|
||||
xxx = (xx[i]) / (zz[i]);
|
||||
yyy = (yy[i]) / (zz[i])--;
|
||||
//var x: number = xxx + game.input.x;
|
||||
//var y: number = yyy + game.input.y;
|
||||
var x = xxx + 400;
|
||||
var y = yyy + 300;
|
||||
var c = '#ffffff';
|
||||
//if (zz[i] > 80) c = '#666666';
|
||||
//else if (zz[i] > 60) c = '#888888'
|
||||
//else if (zz[i] > 40) c = '#aaaaaa';
|
||||
starfield.setPixel(x, y, c);
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
starfield.render();
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,66 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var starfield: Phaser.DynamicTexture;
|
||||
|
||||
var xx = [];
|
||||
var yy = [];
|
||||
var zz = [];
|
||||
var xxx = 0;
|
||||
var yyy = 0;
|
||||
|
||||
function create() {
|
||||
|
||||
// The width of the starfield
|
||||
var star_w: number = 12000;
|
||||
|
||||
for (var i: number = 0; i < 800; i++)
|
||||
{
|
||||
xx[i] = Math.floor(Math.random() * star_w * 2) - star_w
|
||||
yy[i] = Math.floor(Math.random() * star_w * 2) - star_w
|
||||
zz[i] = Math.floor(Math.random() * 160) + 1;
|
||||
}
|
||||
|
||||
starfield = game.add.dynamicTexture(800, 600);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
starfield.clear();
|
||||
|
||||
for (var i: number = 0; i < 800; i++)
|
||||
{
|
||||
if (zz[i] == 1)
|
||||
{
|
||||
zz[i] = 100;
|
||||
}
|
||||
|
||||
xxx = (xx[i]) / (zz[i]);
|
||||
yyy = (yy[i]) / (zz[i])--;
|
||||
|
||||
//var x: number = xxx + game.input.x;
|
||||
//var y: number = yyy + game.input.y;
|
||||
var x: number = xxx + 400;
|
||||
var y: number = yyy + 300;
|
||||
var c: string = '#ffffff';
|
||||
|
||||
//if (zz[i] > 80) c = '#666666';
|
||||
//else if (zz[i] > 60) c = '#888888'
|
||||
//else if (zz[i] > 40) c = '#aaaaaa';
|
||||
|
||||
starfield.setPixel(x, y, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
starfield.render();
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = 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
|
||||
game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
game.load.start();
|
||||
}
|
||||
var bits;
|
||||
var bot;
|
||||
function create() {
|
||||
bot = game.add.sprite(800, 200, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 20, true);
|
||||
bits = game.add.sprite(200, 200, 'bits');
|
||||
bits.frame = 0;
|
||||
}
|
||||
function update() {
|
||||
bot.x -= 5;
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = game.stage.width;
|
||||
bits.frame++;
|
||||
if(bits.frame == bits.animations.frameTotal - 1) {
|
||||
bits.frame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,51 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = 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
|
||||
game.load.atlas('bits', 'assets/sprites/shoebox.png', 'assets/sprites/shoebox.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
game.load.atlas('bot', 'assets/sprites/shoebot.png', 'assets/sprites/shoebot.xml', null, Phaser.Loader.TEXTURE_ATLAS_XML_STARLING);
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var bits: Phaser.Sprite;
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = game.add.sprite(800, 200, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 20, true);
|
||||
|
||||
bits = game.add.sprite(200, 200, 'bits');
|
||||
bits.frame = 0;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
bot.x -= 5;
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = game.stage.width;
|
||||
|
||||
bits.frame++;
|
||||
|
||||
if (bits.frame == bits.animations.frameTotal - 1)
|
||||
{
|
||||
bits.frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
function init() {
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
game.load.start();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = game.add.sprite(400, 300, 'bot');
|
||||
bot.animations.add('run', null, 20, true);
|
||||
bot.animations.play('run');
|
||||
}
|
||||
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 }}]}';
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, init, create);
|
||||
|
||||
function init() {
|
||||
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
// In this example we assume that the TexturePacker JSON data is a string of json data stored as a var
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = game.add.sprite(400, 300, 'bot');
|
||||
|
||||
bot.animations.add('run', null, 20, true);
|
||||
|
||||
bot.animations.play('run');
|
||||
|
||||
}
|
||||
|
||||
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 }}]}';
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,271 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = 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 real json object stored as a var
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
game.load.start();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = game.add.sprite(game.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
}
|
||||
function update() {
|
||||
bot.x -= 2;
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = game.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$"
|
||||
}
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,143 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = 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 real json object stored as a var
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = game.add.sprite(game.stage.width, 300, 'bot');
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
bot.x -= 2;
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = game.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$"
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = 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
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
game.load.start();
|
||||
}
|
||||
var bot;
|
||||
function create() {
|
||||
bot = game.add.sprite(game.stage.width, 300, 'bot');
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
}
|
||||
function update() {
|
||||
bot.x -= 2;
|
||||
if(bot.x < -bot.width) {
|
||||
bot.x = game.stage.width;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,40 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = 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
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var bot: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
bot = game.add.sprite(game.stage.width, 300, 'bot');
|
||||
|
||||
bot.animations.add('run');
|
||||
bot.animations.play('run', 10, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
bot.x -= 2;
|
||||
|
||||
if (bot.x < -bot.width)
|
||||
{
|
||||
bot.x = game.stage.width;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,32 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = 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
|
||||
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
game.load.start();
|
||||
}
|
||||
var chick;
|
||||
var car;
|
||||
var mech;
|
||||
var robot;
|
||||
var cop;
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(40, 40, 40)';
|
||||
chick = game.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 = game.add.sprite(600, 64, 'atlas');
|
||||
cop.frameName = 'ladycop.png';
|
||||
robot = game.add.sprite(50, 300, 'atlas');
|
||||
robot.frameName = 'robot.png';
|
||||
car = game.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
mech = game.add.sprite(250, 100, 'atlas');
|
||||
mech.frameName = 'titan_mech.png';
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,50 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var game = 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
|
||||
game.load.atlas('atlas', 'assets/pics/texturepacker_test.png', 'assets/pics/texturepacker_test.json');
|
||||
|
||||
game.load.start();
|
||||
|
||||
}
|
||||
|
||||
var chick: Phaser.Sprite;
|
||||
var car: Phaser.Sprite;
|
||||
var mech: Phaser.Sprite;
|
||||
var robot: Phaser.Sprite;
|
||||
var cop: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = 'rgb(40, 40, 40)';
|
||||
|
||||
chick = game.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 = game.add.sprite(600, 64, 'atlas');
|
||||
cop.frameName = 'ladycop.png';
|
||||
|
||||
robot = game.add.sprite(50, 300, 'atlas');
|
||||
robot.frameName = 'robot.png';
|
||||
|
||||
car = game.add.sprite(100, 400, 'atlas');
|
||||
car.frameName = 'supercars_parsec.png';
|
||||
|
||||
mech = game.add.sprite(250, 100, 'atlas');
|
||||
mech.frameName = 'titan_mech.png';
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user