mirror of
https://github.com/wassname/phaser.git
synced 2026-08-10 12:30:48 +08:00
yuidoc scripts added. Tidied up the Docs folder. Added back in the Emitter and fixed the Tests that weren't compiling.
This commit is contained in:
@@ -1,55 +1,62 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
}
|
||||
|
||||
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++) {
|
||||
|
||||
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) {
|
||||
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) {
|
||||
|
||||
if (waveDataCounter == waveData.length) {
|
||||
waveDataCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
var wobblyBall: Phaser.DynamicTexture;
|
||||
var wobblyBall: Phaser.Display.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,41 +1,52 @@
|
||||
/// <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++) {
|
||||
|
||||
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) {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, null, create, update, render);
|
||||
|
||||
var starfield: Phaser.DynamicTexture;
|
||||
var starfield: Phaser.Display.DynamicTexture;
|
||||
|
||||
var xx = [];
|
||||
var yy = [];
|
||||
|
||||
@@ -1,38 +1,42 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/large-color-wheel.png');
|
||||
game.load.image('coke', 'assets/sprites/cokecan.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
}
|
||||
|
||||
var hue = 0;
|
||||
var texture;
|
||||
|
||||
function create() {
|
||||
game.world.setSize(800, 800);
|
||||
|
||||
texture = game.add.dynamicTexture(800, 600);
|
||||
|
||||
var backdrop = game.add.sprite(0, 0, 'backdrop');
|
||||
var cokecan = game.add.sprite(30, 20, 'coke');
|
||||
var mushroom = game.add.sprite(600, 20, 'mushroom');
|
||||
texture.assignCanvasToGameObjects([
|
||||
backdrop,
|
||||
cokecan,
|
||||
mushroom
|
||||
]);
|
||||
|
||||
texture.assignCanvasToGameObjects([backdrop, cokecan, mushroom]);
|
||||
|
||||
// Rats, filters don't get applied when the canvas is drawn to another canvas. Oh well :)
|
||||
texture.css3.grayscale = 100;
|
||||
}
|
||||
|
||||
function update() {
|
||||
// The value is given in degrees, so between 0 and 360, hence the wrapValue call below.
|
||||
hue = game.math.wrapValue(hue, 1, 360);
|
||||
// Apply a hue rotation to the stage
|
||||
//game.stage.css3.hueRotate = hue;
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
game.camera.y -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
game.camera.y += 4;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
texture.render();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
var hue: number = 0;
|
||||
var texture: Phaser.DynamicTexture;
|
||||
var texture: Phaser.Display.DynamicTexture;
|
||||
|
||||
function create() {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// Starling/Sparrow XML Texture Atlas Method 1
|
||||
//
|
||||
@@ -8,21 +9,28 @@
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (bot.x < -bot.width) {
|
||||
bot.x = game.stage.width;
|
||||
|
||||
bits.frame++;
|
||||
if(bits.frame == bits.animations.frameTotal - 1) {
|
||||
|
||||
if (bits.frame == bits.animations.frameTotal - 1) {
|
||||
bits.frame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Texture Atlas Method 1
|
||||
//
|
||||
@@ -8,11 +9,16 @@
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
}
|
||||
|
||||
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 }}]}';
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// Texture Atlas Method 2
|
||||
//
|
||||
@@ -8,250 +9,113 @@
|
||||
// (in this case botData)
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
},
|
||||
"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
|
||||
},
|
||||
"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
|
||||
}
|
||||
"spriteSourceSize": { "x": 0, "y": 3, "w": 56, "h": 58 },
|
||||
"sourceSize": { "w": 56, "h": 64 }
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
@@ -259,10 +123,7 @@
|
||||
"version": "1.0",
|
||||
"image": "running_bot.png",
|
||||
"format": "RGBA8888",
|
||||
"size": {
|
||||
"w": 252,
|
||||
"h": 256
|
||||
},
|
||||
"size": { "w": 252, "h": 256 },
|
||||
"scale": "0.2",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:fb56f261b1eb04e3215824426595f64c$"
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// 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');
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
if (bot.x < -bot.width) {
|
||||
bot.x = game.stage.width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,39 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// 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');
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user