mirror of
https://github.com/wassname/phaser.git
synced 2026-07-27 11:25:30 +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
-20
@@ -118,7 +118,6 @@
|
||||
<Content Include="cameras\scrollfactor 2.js">
|
||||
<DependentUpon>scrollfactor 2.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\graphic emitter.ts" />
|
||||
<TypeScriptCompile Include="input\over sprite 1.ts" />
|
||||
<TypeScriptCompile Include="groups\create group 1.ts" />
|
||||
<TypeScriptCompile Include="cameras\world sprite.ts" />
|
||||
@@ -252,25 +251,6 @@
|
||||
<Content Include="mobile\sprite test 1.js">
|
||||
<DependentUpon>sprite test 1.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="particles\graphic emitter.js">
|
||||
<DependentUpon>graphic emitter.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\multiple streams.ts" />
|
||||
<TypeScriptCompile Include="particles\mousetrail.ts" />
|
||||
<Content Include="particles\mousetrail.js">
|
||||
<DependentUpon>mousetrail.ts</DependentUpon>
|
||||
</Content>
|
||||
<Content Include="particles\multiple streams.js">
|
||||
<DependentUpon>multiple streams.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\sprite emitter.ts" />
|
||||
<Content Include="particles\sprite emitter.js">
|
||||
<DependentUpon>sprite emitter.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="particles\when particles collide.ts" />
|
||||
<Content Include="particles\when particles collide.js">
|
||||
<DependentUpon>when particles collide.ts</DependentUpon>
|
||||
</Content>
|
||||
<TypeScriptCompile Include="scrollzones\simple scrollzone.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\scroll window.ts" />
|
||||
<TypeScriptCompile Include="scrollzones\region demo.ts" />
|
||||
@@ -462,6 +442,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="animation\" />
|
||||
<Folder Include="particles\" />
|
||||
<Folder Include="physics\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
|
||||
|
||||
@@ -4,37 +4,40 @@
|
||||
//var PhaserGlobal = { disableWebAudio: true };
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
game.load.audio('rabbit', [
|
||||
'assets/mp3/peter_rabbit.m4a',
|
||||
'assets/mp3/peter_rabbit.mp3',
|
||||
'assets/mp3/peter_rabbit.ogg'
|
||||
]);
|
||||
game.load.audio('rabbit', ['assets/mp3/peter_rabbit.m4a', 'assets/mp3/peter_rabbit.mp3', 'assets/mp3/peter_rabbit.ogg']);
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
audioSprite:
|
||||
Phaser.Sound
|
||||
Phaser.Sound;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
pause:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
this.audioSprite = game.add.audio('rabbit');
|
||||
this.audioSprite.addMarker('title', 3.00, 5.00, 1, true);
|
||||
this.audioSprite.addMarker('help', 6.00, 12.00);
|
||||
this.audioSprite.addMarker('intro', 14.00, 19.00);
|
||||
this.audioSprite.addMarker('peter', 20.00, 21.50);
|
||||
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', playMusic, this, 2, 1, 0);
|
||||
//this.pause = game.add.button(200, 200, 'button', togglePause, this, 2, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function playMusic() {
|
||||
this.audioSprite.play('help');
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderSoundInfo(this.audioSprite, 32, 32);
|
||||
}
|
||||
|
||||
function togglePause() {
|
||||
if(this.music.paused) {
|
||||
if (this.music.paused) {
|
||||
this.music.resume();
|
||||
} else {
|
||||
this.music.pause();
|
||||
|
||||
+17
-10
@@ -4,50 +4,57 @@
|
||||
//var PhaserGlobal = { fakeiOSTouchLock: true, disableWebAudio: true };
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
//game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']);
|
||||
game.load.audio('boden', [
|
||||
'assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3'
|
||||
]);
|
||||
game.load.audio('boden', ['assets/mp3/bodenstaendig_2000_in_rock_4bit.mp3']);
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
music:
|
||||
Phaser.Sound
|
||||
Phaser.Sound;
|
||||
volumeUp:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
volumeDown:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
pause:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
this.music = game.add.audio('boden');
|
||||
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', playMusic, this, 2, 1, 0);
|
||||
//this.volumeUp = game.add.button(0, 0, 'button', volUp, this, 2, 1, 0);
|
||||
//this.volumeDown = game.add.button(700, 0, 'button', volDown, this, 2, 1, 0);
|
||||
//this.pause = game.add.button(200, 200, 'button', togglePause, this, 2, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderSoundInfo(this.music, 0, 300);
|
||||
}
|
||||
|
||||
function togglePause() {
|
||||
if(this.music.paused) {
|
||||
if (this.music.paused) {
|
||||
this.music.resume();
|
||||
} else {
|
||||
this.music.pause();
|
||||
}
|
||||
}
|
||||
|
||||
function volUp() {
|
||||
//game.sound.volume += 0.1;
|
||||
this.music.volume += 0.1;
|
||||
console.log('vol up', game.sound.volume);
|
||||
}
|
||||
|
||||
function volDown() {
|
||||
//game.sound.volume -= 0.1;
|
||||
this.music.volume -= 0.1;
|
||||
console.log('vol down', game.sound.volume);
|
||||
}
|
||||
|
||||
function playMusic() {
|
||||
this.music.play();
|
||||
}
|
||||
|
||||
@@ -2,28 +2,34 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
|
||||
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a texture atlas.
|
||||
// Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
|
||||
// In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
|
||||
|
||||
// Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
@@ -2,29 +2,35 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a sprite sheet.
|
||||
// Frame 0 = the 'down' state
|
||||
// Frame 1 = the 'out' state
|
||||
// Frame 2 = the 'over' state
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 2, 1, 0);
|
||||
|
||||
// Just makes the button origin set to the middle, we only do this to center the button on-screen, no other reason
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
@@ -2,25 +2,32 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
game.load.spritesheet('button', 'assets/buttons/button_sprite_sheet.png', 193, 71);
|
||||
}
|
||||
|
||||
var button;
|
||||
var secondCam;
|
||||
|
||||
function create() {
|
||||
button = game.add.button(200, 400, 'button', clickedIt, this, 2, 1, 0);
|
||||
button.origin.setTo(0.5, 0.5);
|
||||
|
||||
game.camera.width = 400;
|
||||
game.camera.texture.opaque = true;
|
||||
game.camera.texture.backgroundColor = 'rgb(100,0,0)';
|
||||
|
||||
secondCam = game.add.camera(400, 0, 400, 600);
|
||||
secondCam.texture.opaque = true;
|
||||
secondCam.texture.backgroundColor = 'rgb(0,100,0)';
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteWorldView(button, 32, 200);
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
button.rotation += 10;
|
||||
}
|
||||
|
||||
@@ -2,32 +2,39 @@
|
||||
/// <reference path="../../Phaser/ui/Button.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_other_world.png');
|
||||
game.load.atlas('button', 'assets/buttons/button_texture_atlas.png', 'assets/buttons/button_texture_atlas.json');
|
||||
}
|
||||
|
||||
image:
|
||||
Phaser.Sprite
|
||||
Phaser.Sprite;
|
||||
button:
|
||||
Phaser.UI.Button
|
||||
Phaser.UI.Button;
|
||||
|
||||
function create() {
|
||||
// This is just an image that we'll toggle the display of when you click the button
|
||||
this.image = game.add.sprite(game.stage.centerX, 0, 'beast');
|
||||
this.image.transform.origin.setTo(0.5, 0);
|
||||
|
||||
// This button is created from a texture atlas.
|
||||
// Instead of frame IDs (like with a sprite sheet) we can tell it to use frame names instead.
|
||||
// In this case our atlast frame names were called 'over', 'out' and 'down', but they could be anything you want.
|
||||
// The function "clickedIt" will be called when the button is clicked or touched
|
||||
this.button = game.add.button(game.stage.centerX, 400, 'button', clickedIt, this, 'over', 'out', 'down');
|
||||
|
||||
// Makes the button origin set to the middle
|
||||
this.button.transform.origin.setTo(0.5, 0.5);
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Rotate the button each frame, the button states will still work and respond.
|
||||
this.button.rotation += 1;
|
||||
}
|
||||
|
||||
function clickedIt() {
|
||||
if(this.image.visible == true) {
|
||||
if (this.image.visible == true) {
|
||||
this.image.visible = false;
|
||||
} else {
|
||||
this.image.visible = true;
|
||||
|
||||
@@ -2,22 +2,29 @@
|
||||
/// <reference path="../../Plugins/CameraFX/Mirror.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
}
|
||||
|
||||
var mirror;
|
||||
|
||||
function create() {
|
||||
// Just set the world to be the size of the image we're loading in
|
||||
game.world.setSize(1216, 896);
|
||||
|
||||
// What we need is a camera 800x400 pixels in size as the mirror effect will be 200px tall and sit below it.
|
||||
// So we resize our default camera to 400px
|
||||
game.camera.height = 400;
|
||||
|
||||
// Add our effect to the camera
|
||||
mirror = game.camera.plugins.add(Phaser.Plugins.CameraFX.Mirror);
|
||||
|
||||
// The first 2 parameters are the x and y coordinates of where to display the effect. They are in STAGE coordinates, not World.
|
||||
// The next is a Rectangle making up the region of the Camera that we'll create the effect from (in this case the whole camera).
|
||||
// Finally we set the fill color that is put over the top of the mirror effect.
|
||||
mirror.start(0, 400, new Phaser.Rectangle(0, 0, 800, 400), 'rgba(0, 0, 100, 0.7)');
|
||||
|
||||
// Experiment with variations on these to see the different mirror effects that can be achieved.
|
||||
//mirror.flipX = true;
|
||||
//mirror.flipY = true;
|
||||
@@ -25,15 +32,17 @@
|
||||
// just a single image, but when used on a full game it can look really quite neat.
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,38 @@
|
||||
/// <reference path="../../Plugins/CameraFX/Scanlines.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/ninja-masters2.png');
|
||||
}
|
||||
|
||||
var scanlines;
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1216, 896);
|
||||
|
||||
// Add our effect to the camera
|
||||
scanlines = game.camera.plugins.add(Phaser.Plugins.CameraFX.Scanlines);
|
||||
|
||||
// We'll have the scanlines spaced out every 2 pixels
|
||||
scanlines.spacing = 2;
|
||||
|
||||
// This is the color the lines will be drawn in
|
||||
scanlines.color = 'rgba(0, 0, 0, 0.8)';
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
/// <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/remember-me.jpg');
|
||||
game.load.image('melon', 'assets/sprites/melon.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
for(var i = 0; i < 100; i++) {
|
||||
|
||||
for (var i = 0; i < 100; i++) {
|
||||
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
|
||||
}
|
||||
|
||||
//game.camera.texture.alpha = 0.5;
|
||||
//game.camera.width = 400;
|
||||
game.camera.texture.opaque = true;
|
||||
@@ -19,24 +24,28 @@
|
||||
game.camera.setPosition(game.stage.centerX, game.stage.centerY);
|
||||
//game.camera.setPosition(0, 0);
|
||||
//console.log('cam', game.camera.width, game.camera.height);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
game.camera.rotation++;
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.rotation--;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
//game.camera.x -= 4;
|
||||
game.camera.transform.scale.x -= 0.1;
|
||||
game.camera.transform.scale.y -= 0.1;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
//game.camera.x += 4;
|
||||
game.camera.transform.scale.x += 0.1;
|
||||
game.camera.transform.scale.y += 0.1;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
function update() {
|
||||
|
||||
game.camera.rotation++;
|
||||
game.camera.rotation--;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
var ufo;
|
||||
var speed = 4;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1280, 600, true);
|
||||
game.load.image('ground', 'assets/tests/ground-2x.png');
|
||||
@@ -11,6 +13,7 @@
|
||||
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
|
||||
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
|
||||
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
|
||||
|
||||
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
|
||||
}
|
||||
function create() {
|
||||
@@ -21,27 +24,29 @@
|
||||
game.add.sprite(200, 120, 'cloud0').transform.scrollFactor.setTo(0.3, 0.3);
|
||||
game.add.sprite(-60, 120, 'cloud1').transform.scrollFactor.setTo(0.5, 0.3);
|
||||
game.add.sprite(900, 170, 'cloud2').transform.scrollFactor.setTo(0.7, 0.3);
|
||||
|
||||
// ufo spirte
|
||||
ufo = game.add.sprite(320, 240, 'ufo');
|
||||
ufo.animations.add('fly', null, 30, false);
|
||||
ufo.animations.play('fly');
|
||||
ufo.transform.origin.setTo(0.5, 0.5);
|
||||
|
||||
// make camera follows ufo
|
||||
game.camera.follow(ufo);
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
ufo.x -= speed;
|
||||
ufo.rotation = -15;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
ufo.x += speed;
|
||||
ufo.rotation = 15;
|
||||
} else {
|
||||
ufo.rotation = 0;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
ufo.y -= speed;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
ufo.y += speed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,40 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.load.image('car', 'assets/sprites/car90.png');
|
||||
}
|
||||
|
||||
var car;
|
||||
var miniCam;
|
||||
|
||||
function create() {
|
||||
game.world.setSize(2240, 2240, true);
|
||||
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
|
||||
car = game.add.sprite(400, 300, 'car');
|
||||
|
||||
game.camera.follow(car, Phaser.Types.CAMERA_FOLLOW_TOPDOWN);
|
||||
|
||||
miniCam = game.add.camera(0, 0, 300, 300);
|
||||
miniCam.follow(car, Phaser.Types.CAMERA_FOLLOW_TOPDOWN_TIGHT);
|
||||
miniCam.setBounds(0, 0, game.world.width, game.world.height);
|
||||
miniCam.texture.alpha = 0.7;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.x += 4;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
car.y -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
car.y += 4;
|
||||
}
|
||||
/*
|
||||
@@ -50,7 +59,8 @@
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderSpriteInfo(car, 32, 32);
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 300);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
var btn1, btn2, btn3;
|
||||
var fx;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(800, 600, true);
|
||||
game.load.image('blue', 'assets/tests/blue-circle.png');
|
||||
@@ -14,7 +16,7 @@
|
||||
btn2 = game.add.button(426, 86, 'yellow', forceFade, this);
|
||||
btn3 = game.add.button(221, 318, 'magenta', fadeWithCallback, this);
|
||||
//fx = game.camera.fx.add(Phaser.FX.Camera.Fade);
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
Phaser.DebugUtils.context.fillStyle = '#fff';
|
||||
Phaser.DebugUtils.context.fillText('Press to fade.', 114 + 90, 34 + 130);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
var btn1, btn2, btn3;
|
||||
var fx;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(800, 600, true);
|
||||
game.load.image('blue', 'assets/tests/blue-circle.png');
|
||||
@@ -15,7 +17,7 @@
|
||||
btn3 = game.add.button(221, 318, 'magenta', flashWithCallback, this);
|
||||
// Usage of flash fx is the same as fade.
|
||||
//fx = game.camera.fx.add(Phaser.FX.Camera.Flash);
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
Phaser.DebugUtils.context.fillStyle = '#fff';
|
||||
Phaser.DebugUtils.context.fillText('Press to flash.', 114 + 90, 34 + 130);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
var btn1, btn2, btn3;
|
||||
var fx;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(800, 600, true);
|
||||
game.load.image('blue', 'assets/tests/blue-circle.png');
|
||||
@@ -15,7 +17,7 @@
|
||||
btn3 = game.add.button(221, 318, 'magenta', shakeWithCallback, this);
|
||||
// Usage of shake fx is the same as fade and flash.
|
||||
//fx = game.camera.fx.add(Phaser.FX.Camera.Shake);
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
Phaser.DebugUtils.context.fillStyle = '#fff';
|
||||
Phaser.DebugUtils.context.fillText('Press to shake.', 114 + 90, 34 + 130);
|
||||
|
||||
@@ -1,36 +1,45 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('melon', 'assets/sprites/melon.png');
|
||||
}
|
||||
|
||||
var car;
|
||||
var miniCam;
|
||||
|
||||
function create() {
|
||||
game.world.setSize(3000, 3000, true);
|
||||
game.stage.backgroundColor = 'rgb(20,20,50)';
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
|
||||
}
|
||||
|
||||
game.camera.transform.origin.setTo(0.5, 0.5);
|
||||
game.camera.texture.opaque = true;
|
||||
game.camera.texture.backgroundColor = 'rgb(0,0,0)';
|
||||
game.camera.setPosition(game.stage.centerX, game.stage.centerY);
|
||||
|
||||
//game.camera.setPosition(200, 0);
|
||||
game.camera.setSize(320, 320);
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.rotation -= 2;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.rotation += 2;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
var zombieCamera;
|
||||
|
||||
var zombie;
|
||||
var walkSpeed = 2, direction = 1;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1280, 600, true);
|
||||
game.load.image('ground', 'assets/tests/ground-2x.png');
|
||||
game.load.image('river', 'assets/tests/river-2x.png');
|
||||
game.load.image('sky', 'assets/tests/sky-2x.png');
|
||||
|
||||
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
||||
}
|
||||
function create() {
|
||||
@@ -16,40 +20,48 @@
|
||||
game.add.sprite(0, 0, 'sky');
|
||||
game.add.sprite(0, 360, 'ground');
|
||||
game.add.sprite(0, 400, 'river');
|
||||
|
||||
// Create zombie spirte
|
||||
zombie = game.add.sprite(480, 336, 'zombie');
|
||||
zombie.animations.add('walk', null, 30, true);
|
||||
zombie.animations.play('walk');
|
||||
|
||||
// Create a small camera which looks at the zombie.
|
||||
// Use the same settings as the default camera.
|
||||
zombieCamera = game.add.camera(0, 0, 800, 600);
|
||||
|
||||
// Use x and y properties to set the target area.
|
||||
zombieCamera.x = 420;
|
||||
zombieCamera.y = 240;
|
||||
|
||||
// Resize the camera so that it will only look at 200x200 area.
|
||||
zombieCamera.setSize(200, 200);
|
||||
|
||||
// Scale the camera to 2.0, now its target will be 100x100.
|
||||
zombieCamera.transform.scale.setTo(2.0, 2.0);
|
||||
|
||||
// Use setPosition() method to set where the camera rendered
|
||||
// on the screen.
|
||||
zombieCamera.setPosition(0, 0);
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
zombieCamera.x -= 2;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
zombieCamera.x += 2;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
zombieCamera.y -= 2;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
zombieCamera.y += 2;
|
||||
}
|
||||
|
||||
// zombie wandering update
|
||||
zombie.x += walkSpeed * direction;
|
||||
if(zombie.x > 540 || zombie.x < 440) {
|
||||
if (zombie.x > 540 || zombie.x < 440) {
|
||||
// Change walk direction.
|
||||
direction *= -1;
|
||||
|
||||
// Flip zombie's animation.
|
||||
zombie.texture.flippedX = !zombie.texture.flippedX;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(800, 600, true);
|
||||
game.load.image('background', 'assets/misc/water_texture.jpg');
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
var ufo, speed = 4;
|
||||
|
||||
var btn0, btn1, btn2, btn3;
|
||||
var style = 'default';
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1280, 800, true);
|
||||
game.load.image('ground', 'assets/tests/ground-2x.png');
|
||||
@@ -12,7 +15,9 @@
|
||||
game.load.image('cloud0', 'assets/tests/cloud-big-2x.png');
|
||||
game.load.image('cloud1', 'assets/tests/cloud-narrow-2x.png');
|
||||
game.load.image('cloud2', 'assets/tests/cloud-small-2x.png');
|
||||
|
||||
game.load.spritesheet('button', 'assets/buttons/follow-style-button.png', 224, 70);
|
||||
|
||||
game.load.spritesheet('ufo', 'assets/sprites/ufo.png', 24, 21);
|
||||
}
|
||||
function create() {
|
||||
@@ -23,13 +28,16 @@
|
||||
game.add.sprite(200, 120, 'cloud0').transform.scrollFactor.setTo(0.3, 0.1);
|
||||
game.add.sprite(-60, 120, 'cloud1').transform.scrollFactor.setTo(0.5, 0.1);
|
||||
game.add.sprite(900, 170, 'cloud2').transform.scrollFactor.setTo(0.7, 0.1);
|
||||
|
||||
// ufo spirte
|
||||
ufo = game.add.sprite(360, 240, 'ufo');
|
||||
ufo.animations.add('fly', null, 30, false);
|
||||
ufo.animations.play('fly');
|
||||
ufo.transform.origin.setTo(0.5, 0.5);
|
||||
|
||||
// make camera follows ufo
|
||||
game.camera.follow(ufo);
|
||||
|
||||
// follow style switch buttons
|
||||
btn0 = game.add.button(16, 40, 'button', lockonFollow, 0, 0, 0);
|
||||
btn1 = game.add.button(16, 120, 'button', platformerFollow, 1, 1, 1);
|
||||
@@ -37,25 +45,26 @@
|
||||
btn3 = game.add.button(16, 280, 'button', topdownTightFollow, 3, 3, 3);
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
ufo.x -= speed;
|
||||
ufo.rotation = -15;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
ufo.x += speed;
|
||||
ufo.rotation = 15;
|
||||
} else {
|
||||
ufo.rotation = 0;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
ufo.y -= speed;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
ufo.y += speed;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
if(game.camera.deadzone) {
|
||||
if (game.camera.deadzone) {
|
||||
Phaser.DebugUtils.renderRectangle(game.camera.deadzone, 'rgba(240, 112, 111, 0.4)');
|
||||
}
|
||||
|
||||
// game.camera.renderDebugInfo(400, 16);
|
||||
Phaser.DebugUtils.context.fillStyle = '#fff';
|
||||
Phaser.DebugUtils.context.fillText('Click buttons to switch between different styles.', 360, 32);
|
||||
|
||||
@@ -1,43 +1,54 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
var radar;
|
||||
var ships = [];
|
||||
|
||||
var enemyCamera;
|
||||
|
||||
function preload() {
|
||||
game.load.image('radar-surface', 'assets/tests/radar-surface.png');
|
||||
game.load.image('ship', 'assets/sprites/asteroids_ship_white.png');
|
||||
game.load.image('enemy-ship', 'assets/sprites/asteroids_ship.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// Add enemies and our ship the the world.
|
||||
for(var i = 0; i < 4; i++) {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
ships.push(game.add.sprite(100 + i * 10, 280 + i * 16, 'enemy-ship'));
|
||||
}
|
||||
|
||||
var ourShip = game.add.sprite(160, 300, 'ship');
|
||||
ships.push(ourShip);
|
||||
|
||||
// Radar sprite is a HUD.
|
||||
radar = game.add.sprite(0, 0, 'radar-surface');
|
||||
|
||||
// Make the default camera rendered on the left half screen.
|
||||
game.camera.setSize(400, 600);
|
||||
game.camera.texture.backgroundColor = 'rgb(0,50,100)';
|
||||
game.camera.texture.opaque = true;
|
||||
|
||||
// Add a new camera and render it on the right half screen.
|
||||
// The newly created is the enemies' camera, which cannot "see" our ship.
|
||||
enemyCamera = game.add.camera(400, 0, 400, 600);
|
||||
enemyCamera.texture.backgroundColor = 'rgb(100,0,50)';
|
||||
enemyCamera.texture.opaque = true;
|
||||
|
||||
// Hide our ship on the enemies' camera.
|
||||
enemyCamera.hide(ourShip);
|
||||
}
|
||||
|
||||
function update() {
|
||||
for(var i = 0; i < ships.length; i++) {
|
||||
for (var i = 0; i < ships.length; i++) {
|
||||
ships[i].x += 4;
|
||||
if(ships[i].x > 400) {
|
||||
|
||||
if (ships[i].x > 400) {
|
||||
ships[i].x = 40;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderText('Left is the player\'s camera and right is the enemies\' camera.', 32, 32);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
var zombieCamera;
|
||||
|
||||
var zombie;
|
||||
var walkSpeed = 2, direction = 1;
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1280, 600, true);
|
||||
game.load.image('ground', 'assets/tests/ground-2x.png');
|
||||
game.load.image('river', 'assets/tests/river-2x.png');
|
||||
game.load.image('sky', 'assets/tests/sky-2x.png');
|
||||
|
||||
game.load.spritesheet('zombie', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
||||
}
|
||||
function create() {
|
||||
@@ -16,38 +20,45 @@
|
||||
game.add.sprite(0, 0, 'sky');
|
||||
game.add.sprite(0, 360, 'ground');
|
||||
game.add.sprite(0, 400, 'river');
|
||||
|
||||
// Create zombie spirte
|
||||
zombie = game.add.sprite(480, 336, 'zombie');
|
||||
zombie.animations.add('walk', null, 30, true);
|
||||
zombie.animations.play('walk');
|
||||
|
||||
// Create a small camera which looks at the zombie.
|
||||
// Use the same settings as the default camera.
|
||||
zombieCamera = game.add.camera(0, 0, 800, 600);
|
||||
|
||||
// Use x and y properties to set the target area.
|
||||
zombieCamera.x = 420;
|
||||
zombieCamera.y = 240;
|
||||
|
||||
// Resize the camera so that it will only look at 200x200 area.
|
||||
zombieCamera.setSize(200, 200);
|
||||
|
||||
// Use setPosition() method to set where the camera rendered
|
||||
// on the screen.
|
||||
zombieCamera.setPosition(0, 0);
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
zombieCamera.x -= 2;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
zombieCamera.x += 2;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
zombieCamera.y -= 2;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
zombieCamera.y += 2;
|
||||
}
|
||||
|
||||
// zombie wandering update
|
||||
zombie.x += walkSpeed * direction;
|
||||
if(zombie.x > 540 || zombie.x < 440) {
|
||||
if (zombie.x > 540 || zombie.x < 440) {
|
||||
// Change walk direction.
|
||||
direction *= -1;
|
||||
|
||||
// Flip zombie's animation.
|
||||
zombie.texture.flippedX = !zombie.texture.flippedX;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,37 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
game.load.image('ball', 'assets/sprites/shinyball.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
for(var i = 0; i < 400; i++) {
|
||||
|
||||
for (var i = 0; i < 400; i++) {
|
||||
var tempBall = game.add.sprite(game.world.randomX * 2, game.world.randomY * 2, 'ball');
|
||||
tempBall.transform.scrollFactor.setTo(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
|
||||
}
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1600, 800, true);
|
||||
|
||||
game.load.image('disk', 'assets/pics/devilstar_demo_download_disk.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
for(var i = 0; i < 10; i++) {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var temp = game.add.sprite(600 + (10 * i), 200 + (10 * i), 'disk');
|
||||
temp.transform.scrollFactor.setTo(i / 2, i / 2);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
|
||||
}
|
||||
|
||||
@@ -13,22 +13,24 @@
|
||||
function create() {
|
||||
// background sky, which does not move at all
|
||||
game.add.sprite(0, 0, 'sky').transform.scrollFactor.setTo(0, 0);
|
||||
|
||||
// clouds with different scroll factor which moves slower than camera
|
||||
game.add.sprite(200, 120, 'cloud0').transform.scrollFactor.setTo(0.3, 0.3);
|
||||
game.add.sprite(-60, 120, 'cloud1').transform.scrollFactor.setTo(0.5, 0.3);
|
||||
game.add.sprite(900, 170, 'cloud2').transform.scrollFactor.setTo(0.7, 0.3);
|
||||
|
||||
// forground objects which moves equal or faster than camera
|
||||
game.add.sprite(0, 360, 'ground').transform.scrollFactor.setTo(0.5, 0.5);
|
||||
game.add.sprite(0, 400, 'river').transform.scrollFactor.setTo(1.3, 1.3);
|
||||
}
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 3;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 3;
|
||||
}
|
||||
}
|
||||
function render() {
|
||||
// game.camera.renderDebugInfo(32, 32);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -2,53 +2,39 @@
|
||||
/// <reference path="../../Phaser/utils/DebugUtils.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
game.load.image('ball', 'assets/sprites/mana_card.png');
|
||||
}
|
||||
|
||||
var ball;
|
||||
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
ball = game.add.sprite(200, 200, 'ball');
|
||||
|
||||
ball.body.velocity.x = 50;
|
||||
ball.transform.scale.setTo(2, 2);
|
||||
}
|
||||
|
||||
function update() {
|
||||
/*
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= 4;
|
||||
//ball.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += 4;
|
||||
//ball.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= 4;
|
||||
//ball.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += 4;
|
||||
//ball.y += 4;
|
||||
}
|
||||
*/
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
ball.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
ball.x += 4;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
ball.y -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
|
||||
ball.y += 4;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInfo(ball, 32, 200);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('beast', 'assets/pics/shadow_of_the_beast2_karamoon.png');
|
||||
game.load.image('snot', 'assets/pics/nslide_snot.png');
|
||||
@@ -9,52 +10,66 @@
|
||||
game.load.image('coke', 'assets/sprites/cokecan.png');
|
||||
game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
|
||||
}
|
||||
|
||||
var group1;
|
||||
var group2;
|
||||
var coke;
|
||||
var disk;
|
||||
|
||||
function create() {
|
||||
// Create a background image
|
||||
game.add.sprite(0, 0, 'beast');
|
||||
|
||||
// Create a Group that will sit above the background image
|
||||
group1 = game.add.group(11);
|
||||
|
||||
// Create a Group that will sit above Group 1
|
||||
group2 = game.add.group(11);
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for(var i = 0; i < 10; i++) {
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
//var tempSprite: Phaser.Sprite = group1.addNewSprite(game.stage.randomX, game.stage.randomY, 'atari1');
|
||||
//var tempSprite: Phaser.Sprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'atari1');
|
||||
var tempSprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'atari1');
|
||||
|
||||
tempSprite.name = 'atari' + i;
|
||||
tempSprite.input.start(i, false, true);
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
|
||||
group1.add(tempSprite);
|
||||
|
||||
// Sonics
|
||||
//var tempSprite: Phaser.Sprite = group2.addNewSprite(game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
//var tempSprite: Phaser.Sprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
var tempSprite = game.add.sprite(game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
|
||||
tempSprite.name = 'sonic' + i;
|
||||
tempSprite.input.start(10 + i, false, true);
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
|
||||
group2.add(tempSprite);
|
||||
}
|
||||
|
||||
// Add 2 control sprites into each group - these cannot be dragged but should be bought to the top each time
|
||||
coke = group1.addNewSprite(100, 100, 'coke');
|
||||
disk = group2.addNewSprite(400, 300, 'disk');
|
||||
|
||||
// Create a foreground image - everything should appear behind this, even when dragged
|
||||
var snot = game.add.sprite(game.stage.centerX, game.stage.height, 'snot');
|
||||
snot.origin.setTo(0.5, 1);
|
||||
// You can click and drag any sprite but Sonic sprites should always appear above the Atari sprites
|
||||
// and both types of sprite should only ever appear above the background and behind the
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.justReleased(Phaser.Keyboard.ONE)) {
|
||||
if (game.input.keyboard.justReleased(Phaser.Keyboard.ONE)) {
|
||||
coke.bringToTop();
|
||||
}
|
||||
if(game.input.keyboard.justReleased(Phaser.Keyboard.TWO)) {
|
||||
|
||||
if (game.input.keyboard.justReleased(Phaser.Keyboard.TWO)) {
|
||||
disk.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
}
|
||||
|
||||
var firstGroup;
|
||||
|
||||
function create() {
|
||||
// Here we'll create a new Group
|
||||
firstGroup = game.add.group();
|
||||
// And add some sprites to it
|
||||
for(var i = 0; i < 10; i++) {
|
||||
|
||||
for (var i = 0; i < 10; i++) {
|
||||
// Create a new sprite at a random screen location
|
||||
var newSprite = new Phaser.Sprite(game, game.stage.randomX, game.stage.randomY, 'sonic');
|
||||
|
||||
// This set-ups a listener for the event, view your console.log output to see the result
|
||||
newSprite.events.onAddedToGroup.add(logGroupAdd);
|
||||
|
||||
// Add the sprite to the Group
|
||||
firstGroup.add(newSprite);
|
||||
}
|
||||
}
|
||||
|
||||
function logGroupAdd(sprite, group, zIndex) {
|
||||
console.log('Sprite added to Group', group.ID, 'at z-index:', zIndex);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,38 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('card', 'assets/sprites/mana_card.png');
|
||||
}
|
||||
|
||||
var items;
|
||||
var card;
|
||||
|
||||
function create() {
|
||||
items = game.add.group();
|
||||
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
items.addNewSprite(64, 100, 'atari1');
|
||||
card = items.addNewSprite(240, 80, 'card');
|
||||
items.addNewSprite(280, 100, 'atari2');
|
||||
|
||||
game.input.onTap.addOnce(removeCard, this);
|
||||
}
|
||||
|
||||
function removeCard() {
|
||||
// Now let's kill the card sprite
|
||||
card.kill();
|
||||
|
||||
game.input.onTap.addOnce(replaceCard, this);
|
||||
}
|
||||
|
||||
function replaceCard() {
|
||||
// And bring it back to life again - I assume it will render in the same place as before?
|
||||
var bob = items.getFirstDead();
|
||||
|
||||
bob.revive();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
}
|
||||
|
||||
var atari1;
|
||||
var atari2;
|
||||
|
||||
function create() {
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
atari1 = game.add.sprite(100, 100, 'atari1');
|
||||
atari2 = game.add.sprite(250, 90, 'atari2');
|
||||
|
||||
game.input.onTap.add(swapSprites, this);
|
||||
}
|
||||
|
||||
function swapSprites() {
|
||||
// The 2 Sprites are in the global world Group, but this will work for any Group:
|
||||
game.world.group.swap(atari1, atari2);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
@@ -11,16 +12,18 @@
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// This returns an array of all the image keys in the cache
|
||||
var images = game.cache.getImageKeys();
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for(var i = 0; i < 20; i++) {
|
||||
|
||||
for (var i = 0; i < 20; i++) {
|
||||
var tempSprite = game.add.sprite(game.stage.randomX, game.stage.randomY, game.rnd.pick(images));
|
||||
tempSprite.input.start(i, false, true);
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/atari130xe.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag(true);
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/atari800.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
sprite.input.enableDrag(true);
|
||||
|
||||
// The drag offset allows us to position the sprite relative to the pointer (+ lock) position
|
||||
// In this case it will be positioned -100px above the pointer
|
||||
sprite.input.dragOffset.y = -100;
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/atari800.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
sprite = game.add.sprite(500, 300, 'sprite');
|
||||
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This will ensure the sprite is dragged from its center
|
||||
sprite.input.enableDrag(true);
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderSpriteCorners(sprite);
|
||||
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
|
||||
Phaser.DebugUtils.renderSpriteInfo(sprite, 32, 200);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -2,32 +2,40 @@
|
||||
(function () {
|
||||
// Here we create a tiny game (320x240 in size)
|
||||
var game = new Phaser.Game(this, 'game', 320, 240, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
// This sets a limit on the up-scale
|
||||
game.stage.scale.maxWidth = 800;
|
||||
game.stage.scale.maxHeight = 600;
|
||||
|
||||
// Then we tell Phaser that we want it to scale up to whatever the browser can handle, but to do it proportionally
|
||||
game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
|
||||
game.load.image('melon', 'assets/sprites/melon.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(2000, 2000);
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
|
||||
for (var i = 0; i < 1000; i++) {
|
||||
game.add.sprite(game.world.randomX, game.world.randomY, 'melon');
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderInputInfo(16, 16);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/darkwing_crazy.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
|
||||
// This will lock the sprite so it can only be dragged vertically, not horizontally
|
||||
sprite.input.allowHorizontalDrag = false;
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/parsec.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(85,85,85)';
|
||||
|
||||
sprite = game.add.sprite(200, 400, 'sprite');
|
||||
|
||||
// Enable Input detection. Sprites have this disabled by default,
|
||||
// so you have to start it if you want to interact with them.
|
||||
sprite.input.start(0, false, true);
|
||||
|
||||
// This allows you to drag the sprite. The parameter controls if you drag from the position you touched it (false)
|
||||
// or if it will snap to the center (true)
|
||||
sprite.input.enableDrag();
|
||||
|
||||
// This will lock the sprite so it can only be dragged horizontally, not vertically
|
||||
sprite.input.allowVerticalDrag = false;
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, null, null, null, render);
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderPointer(game.input.pointer1);
|
||||
Phaser.DebugUtils.renderPointer(game.input.pointer2);
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/atari130xe.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
// Enable Input detection
|
||||
sprite.input.start(0, false, true);
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderSpriteInputInfo(sprite, 300, 32);
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('sprite', 'assets/sprites/shinyball.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
|
||||
function create() {
|
||||
// Create a load of sprites
|
||||
for(var i = 0; i < 26; i++) {
|
||||
for (var i = 0; i < 26; i++) {
|
||||
var tempSprite = game.add.sprite(i * 32, 100, 'sprite');
|
||||
tempSprite.input.start(0, false, true);
|
||||
tempSprite.events.onInputOver.add(dropSprite, this);
|
||||
}
|
||||
}
|
||||
|
||||
function dropSprite(sprite) {
|
||||
sprite.body.velocity.y = 300;
|
||||
sprite.input.enabled = false;
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,38 +1,51 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('sprite', 'assets/sprites/atari130xe.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var rotate = false;
|
||||
|
||||
function create() {
|
||||
sprite = game.add.sprite(200, 200, 'sprite');
|
||||
|
||||
game.input.onTap.add(rotateIt, this);
|
||||
}
|
||||
|
||||
function rotateIt() {
|
||||
if(rotate == false) {
|
||||
if (rotate == false) {
|
||||
rotate = true;
|
||||
} else {
|
||||
rotate = false;
|
||||
}
|
||||
}
|
||||
|
||||
var inPoint = false;
|
||||
|
||||
function update() {
|
||||
if(rotate) {
|
||||
if (rotate) {
|
||||
sprite.rotation++;
|
||||
}
|
||||
|
||||
inPoint = Phaser.SpriteUtils.overlapsXY(sprite, game.input.x, game.input.y);
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
|
||||
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
|
||||
game.stage.context.fillText('in: ' + inPoint, 300, 32);
|
||||
|
||||
game.stage.context.restore();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,31 +1,40 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
}
|
||||
|
||||
var atari1;
|
||||
var atari2;
|
||||
var sonic;
|
||||
|
||||
function create() {
|
||||
atari1 = game.add.sprite(200, 200, 'atari1');
|
||||
atari2 = game.add.sprite(500, 400, 'atari2');
|
||||
sonic = game.add.sprite(400, 500, 'sonic');
|
||||
|
||||
atari1.origin.setTo(0.5, 0.5);
|
||||
atari1.rotation = 35;
|
||||
|
||||
atari2.origin.setTo(1, 1);
|
||||
atari2.rotation = 80;
|
||||
|
||||
sonic.rotation = 140;
|
||||
|
||||
atari1.input.start(0, false, true);
|
||||
atari2.input.start(1, false, true);
|
||||
sonic.input.start(2, false, true);
|
||||
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
sonic.input.enableDrag();
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,31 +1,40 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
}
|
||||
|
||||
var atari1;
|
||||
var atari2;
|
||||
var sonic;
|
||||
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
|
||||
atari1 = game.add.sprite(128, 128, 'atari1');
|
||||
atari2 = game.add.sprite(256, 256, 'atari2');
|
||||
|
||||
// Input Enable the sprites
|
||||
atari1.input.start(0, false, true);
|
||||
atari2.input.start(1, false, true);
|
||||
|
||||
// Allow dragging
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
|
||||
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
|
||||
// The snap is set to every 32x32 pixels.
|
||||
atari1.input.enableSnap(32, 32, true, true);
|
||||
|
||||
// For the atari2 sprite it will snap only when released, not on drag.
|
||||
atari2.input.enableSnap(32, 32, false, true);
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, null, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
}
|
||||
|
||||
var atari1;
|
||||
var atari2;
|
||||
var sonic;
|
||||
|
||||
function create() {
|
||||
atari1 = game.add.sprite(100, 100, 'atari1');
|
||||
atari2 = game.add.sprite(300, 200, 'atari2');
|
||||
sonic = game.add.sprite(400, 300, 'sonic');
|
||||
|
||||
atari1.input.start(0, false, true);
|
||||
atari2.input.start(1, false, true);
|
||||
sonic.input.start(2, false, true);
|
||||
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
sonic.input.enableDrag();
|
||||
}
|
||||
|
||||
function render() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
var test;
|
||||
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderInputInfo(32, 32);
|
||||
Phaser.DebugUtils.renderPointer(game.input.activePointer);
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.world.setSize(1920, 1200, true);
|
||||
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
}
|
||||
|
||||
var test;
|
||||
|
||||
function create() {
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
for(var i = 0; i < 50; i++) {
|
||||
|
||||
for (var i = 0; i < 50; i++) {
|
||||
var sprite = game.add.sprite(game.world.randomX, game.world.randomY, 'diamond');
|
||||
sprite.input.start(i, false, true);
|
||||
if(i < 25) {
|
||||
|
||||
if (i < 25) {
|
||||
sprite.input.enableDrag(false);
|
||||
} else {
|
||||
sprite.input.enableDrag(true);
|
||||
@@ -20,18 +26,21 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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() {
|
||||
Phaser.DebugUtils.renderCameraInfo(game.camera, 16, 32);
|
||||
Phaser.DebugUtils.renderInputInfo(16, 200);
|
||||
|
||||
+16
-3
@@ -1,48 +1,61 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('box2', 'assets/tests/320x200.png');
|
||||
game.load.image('box1', 'assets/sprites/oz_pov_melting_disk.png');
|
||||
game.load.image('box', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var rotate = false;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,0)';
|
||||
|
||||
sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'box');
|
||||
|
||||
//sprite.transform.scale.setTo(0.5, 0.5);
|
||||
sprite.transform.origin.setTo(1, 1);
|
||||
|
||||
//sprite.transform.origin.setTo(0.5, 0.5);
|
||||
game.input.onTap.add(rotateIt, this);
|
||||
//game.add.tween(sprite.transform.scale).to({ x: 0.5, y: 0.5 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
}
|
||||
}
|
||||
|
||||
function rotateIt() {
|
||||
if(rotate == false) {
|
||||
if (rotate == false) {
|
||||
rotate = true;
|
||||
} else {
|
||||
rotate = false;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(rotate) {
|
||||
if (rotate) {
|
||||
sprite.rotation++;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
|
||||
|
||||
game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
|
||||
|
||||
game.stage.context.strokeStyle = 'rgb(255,255,0)';
|
||||
game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
|
||||
|
||||
game.stage.context.restore();
|
||||
}
|
||||
})();
|
||||
|
||||
+16
-2
@@ -1,45 +1,59 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var rotate = false;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,0)';
|
||||
|
||||
sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
|
||||
|
||||
sprite.animations.add('walk');
|
||||
sprite.animations.play('walk', 20, true);
|
||||
|
||||
sprite.transform.scale.setTo(4, 4);
|
||||
|
||||
game.input.onTap.add(rotateIt, this);
|
||||
}
|
||||
|
||||
function rotateIt() {
|
||||
if(rotate == false) {
|
||||
if (rotate == false) {
|
||||
rotate = true;
|
||||
} else {
|
||||
rotate = false;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(rotate) {
|
||||
if (rotate) {
|
||||
sprite.rotation++;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
|
||||
|
||||
game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
|
||||
|
||||
game.stage.context.strokeStyle = 'rgb(255,255,0)';
|
||||
game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
|
||||
|
||||
game.stage.context.restore();
|
||||
}
|
||||
})();
|
||||
|
||||
+17
-2
@@ -1,46 +1,61 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.atlas('bot', 'assets/sprites/running_bot.png', null, botData);
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var rotate = false;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,0)';
|
||||
|
||||
sprite = game.add.sprite(game.stage.centerX, game.stage.centerY, 'bot');
|
||||
|
||||
sprite.animations.add('run', null, 10, true);
|
||||
|
||||
sprite.animations.play('run');
|
||||
|
||||
//sprite.transform.scale.setTo(4, 4);
|
||||
game.input.onTap.add(rotateIt, this);
|
||||
}
|
||||
|
||||
function rotateIt() {
|
||||
if(rotate == false) {
|
||||
if (rotate == false) {
|
||||
rotate = true;
|
||||
} else {
|
||||
rotate = false;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(rotate) {
|
||||
if (rotate) {
|
||||
sprite.rotation++;
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgb(255,0,255)';
|
||||
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperLeft.x) + ' y: ' + Math.round(sprite.transform.upperLeft.y), sprite.transform.upperLeft.x, sprite.transform.upperLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.upperRight.x) + ' y: ' + Math.round(sprite.transform.upperRight.y), sprite.transform.upperRight.x, sprite.transform.upperRight.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomLeft.x) + ' y: ' + Math.round(sprite.transform.bottomLeft.y), sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y);
|
||||
game.stage.context.fillText('x: ' + Math.round(sprite.transform.bottomRight.x) + ' y: ' + Math.round(sprite.transform.bottomRight.y), sprite.transform.bottomRight.x, sprite.transform.bottomRight.y);
|
||||
|
||||
game.stage.context.fillRect(sprite.transform.center.x, sprite.transform.center.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperLeft.x, sprite.transform.upperLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.upperRight.x, sprite.transform.upperRight.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomLeft.x, sprite.transform.bottomLeft.y, 2, 2);
|
||||
game.stage.context.fillRect(sprite.transform.bottomRight.x, sprite.transform.bottomRight.y, 2, 2);
|
||||
|
||||
game.stage.context.strokeStyle = 'rgb(255,255,0)';
|
||||
game.stage.context.strokeRect(sprite.cameraView.x, sprite.cameraView.y, sprite.cameraView.width, sprite.cameraView.height);
|
||||
|
||||
game.stage.context.restore();
|
||||
}
|
||||
|
||||
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,45 +1,59 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 320, 400, preload, create);
|
||||
|
||||
var emitter;
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop1', 'assets/pics/atari_fujilogo.png');
|
||||
game.load.image('backdrop2', 'assets/pics/acryl_bladerunner.png');
|
||||
game.load.image('jet', 'assets/sprites/carrot.png');
|
||||
|
||||
// This can help a lot on crappy old Android phones :)
|
||||
//game.framerate = 30;
|
||||
game.stage.backgroundColor = 'rgb(0,0,0)';
|
||||
|
||||
//game.stage.scaleMode = Phaser.StageScaleMode.SHOW_ALL;
|
||||
game.stage.scaleMode = Phaser.StageScaleMode.EXACT_FIT;
|
||||
//game.stage.scaleMode = Phaser.StageScaleMode.NO_SCALE;
|
||||
}
|
||||
}
|
||||
|
||||
var pic1;
|
||||
var pic2;
|
||||
|
||||
function create() {
|
||||
console.log('created now');
|
||||
|
||||
game.stage.enableOrientationCheck(false, true, 'backdrop2');
|
||||
|
||||
pic1 = game.add.sprite(0, 0, 'backdrop1');
|
||||
pic2 = game.add.sprite(0, 0, 'backdrop2');
|
||||
|
||||
// Creates a basic emitter, bursting out 50 default sprites (i.e. 16x16 white boxes)
|
||||
emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
|
||||
emitter.makeParticles('jet', 50, false, 0);
|
||||
emitter.setRotation(0, 0);
|
||||
emitter.start(false, 10, 0.1);
|
||||
|
||||
game.stage.scale.enterLandscape.add(goneLandscape, this);
|
||||
game.stage.scale.enterPortrait.add(gonePortrait, this);
|
||||
|
||||
game.onRenderCallback = render;
|
||||
}
|
||||
|
||||
function goneLandscape() {
|
||||
pic1.visible = true;
|
||||
pic2.visible = false;
|
||||
}
|
||||
|
||||
function gonePortrait() {
|
||||
pic1.visible = false;
|
||||
pic2.visible = true;
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.stage.context.fillStyle = 'rgb(255,0,0)';
|
||||
game.stage.context.font = '20px Arial';
|
||||
//game.stage.context.fillText("ttc: " + game._raf.timeToCall.toString(), 0, 64);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
var emitter;
|
||||
|
||||
function preload() {
|
||||
game.load.image('jet', 'assets/sprites/jets.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
|
||||
emitter.makeParticles('jet', 100, false, 0);
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
var emitter;
|
||||
|
||||
function preload() {
|
||||
game.load.image('jet', 'assets/sprites/particle1.png');
|
||||
game.load.image('starfield', 'assets/misc/starfield.jpg');
|
||||
}
|
||||
|
||||
var scroller;
|
||||
var emitter;
|
||||
|
||||
function create() {
|
||||
scroller = game.add.scrollZone('starfield', 0, 0, 1024, 1024);
|
||||
scroller.setSpeed(0, -1);
|
||||
|
||||
emitter = game.add.emitter(game.stage.centerX, game.stage.centerY);
|
||||
emitter.makeParticles('jet', 200);
|
||||
|
||||
emitter.texture.globalCompositeOperation = 'lighter';
|
||||
|
||||
emitter.gravity = 300;
|
||||
emitter.setXSpeed(-50, 50);
|
||||
emitter.setYSpeed(-50, -100);
|
||||
emitter.setRotation(0, 0);
|
||||
emitter.start(false, 50, 0.02);
|
||||
}
|
||||
|
||||
function update() {
|
||||
emitter.x = game.input.x;
|
||||
emitter.y = game.input.y;
|
||||
//emitter.em
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
var emitter1;
|
||||
var emitter2;
|
||||
var emitter3;
|
||||
var emitter4;
|
||||
var emitter5;
|
||||
var emitter6;
|
||||
|
||||
function preload() {
|
||||
game.load.image('ball1', 'assets/sprites/aqua_ball.png');
|
||||
game.load.image('ball2', 'assets/sprites/yellow_ball.png');
|
||||
@@ -15,19 +17,24 @@
|
||||
game.load.image('ball5', 'assets/sprites/blue_ball.png');
|
||||
game.load.image('ball6', 'assets/sprites/green_ball.png');
|
||||
}
|
||||
|
||||
function makeEmitter(emitter, x, y, graphic) {
|
||||
emitter = game.add.emitter(x, y);
|
||||
emitter.gravity = 100;
|
||||
emitter.bounce = 0.5;
|
||||
if(x == 0) {
|
||||
|
||||
if (x == 0) {
|
||||
emitter.setXSpeed(200, 250);
|
||||
} else {
|
||||
emitter.setXSpeed(-200, -250);
|
||||
}
|
||||
|
||||
emitter.setYSpeed(-50, -10);
|
||||
emitter.makeParticles(graphic, 250, false, 0);
|
||||
|
||||
return emitter;
|
||||
}
|
||||
|
||||
function create() {
|
||||
emitter1 = makeEmitter(emitter1, 0, 50, 'ball1');
|
||||
emitter2 = makeEmitter(emitter2, 0, 250, 'ball2');
|
||||
@@ -35,6 +42,7 @@
|
||||
emitter4 = makeEmitter(emitter4, game.stage.width, 50, 'ball4');
|
||||
emitter5 = makeEmitter(emitter5, game.stage.width, 250, 'ball5');
|
||||
emitter6 = makeEmitter(emitter6, game.stage.width, 450, 'ball6');
|
||||
|
||||
emitter1.start(false, 50, 0.05);
|
||||
emitter2.start(false, 50, 0.05);
|
||||
emitter3.start(false, 50, 0.05);
|
||||
@@ -42,7 +50,8 @@
|
||||
emitter5.start(false, 50, 0.05);
|
||||
emitter6.start(false, 50, 0.05);
|
||||
}
|
||||
|
||||
function update() {
|
||||
//game.collide(leftEmitter, rightEmitter);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeParticle.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeEmitter.ts" />
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeParticle.ts" />
|
||||
/// <reference path="../../Phaser/particles/ArcadeEmitter.ts" />
|
||||
// Actually we could achieve the same result as this by using a sprite sheet and basic Particle
|
||||
// but it still shows you how to use it properly from TypeScript, so it was worth making
|
||||
var customParticle = (function (_super) {
|
||||
__extends(customParticle, _super);
|
||||
function customParticle(game) {
|
||||
_super.call(this, game);
|
||||
var s = [
|
||||
'carrot',
|
||||
'melon',
|
||||
'eggplant',
|
||||
'mushroom',
|
||||
'pineapple'
|
||||
];
|
||||
|
||||
var s = ['carrot', 'melon', 'eggplant', 'mushroom', 'pineapple'];
|
||||
|
||||
this.texture.loadImage(game.math.getRandom(s));
|
||||
}
|
||||
return customParticle;
|
||||
})(Phaser.ArcadeParticle);
|
||||
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
var emitter;
|
||||
|
||||
function preload() {
|
||||
game.load.image('carrot', 'assets/sprites/carrot.png');
|
||||
game.load.image('melon', 'assets/sprites/melon.png');
|
||||
@@ -33,12 +33,15 @@ var customParticle = (function (_super) {
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom.png');
|
||||
game.load.image('pineapple', 'assets/sprites/pineapple.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
emitter = game.add.emitter(game.stage.centerX, 50);
|
||||
emitter.gravity = 100;
|
||||
|
||||
// Here we tell the emitter to use our customParticle class
|
||||
// The customParticle needs to extend Particle and must take game:Game as the first constructor parameter, otherwise it's free as a bird
|
||||
emitter.particleClass = customParticle;
|
||||
|
||||
emitter.makeParticles(null, 500, false, 0);
|
||||
emitter.start(false, 10, 0.05);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
var leftEmitter;
|
||||
var rightEmitter;
|
||||
|
||||
function preload() {
|
||||
game.load.image('ball1', 'assets/sprites/aqua_ball.png');
|
||||
game.load.image('ball2', 'assets/sprites/yellow_ball.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
leftEmitter = game.add.emitter(0, game.stage.centerY - 200);
|
||||
leftEmitter.gravity = 100;
|
||||
@@ -14,16 +17,19 @@
|
||||
leftEmitter.setXSpeed(100, 200);
|
||||
leftEmitter.setYSpeed(-50, 50);
|
||||
leftEmitter.makeParticles('ball1', 250, false, 1);
|
||||
|
||||
rightEmitter = game.add.emitter(game.stage.width + 20, game.stage.centerY - 200);
|
||||
rightEmitter.gravity = 100;
|
||||
rightEmitter.bounce = 0.5;
|
||||
rightEmitter.setXSpeed(-100, -200);
|
||||
rightEmitter.setYSpeed(-50, 50);
|
||||
rightEmitter.makeParticles('ball2', 250, false, 1);
|
||||
|
||||
leftEmitter.start(false, 50, 0.05);
|
||||
rightEmitter.start(false, 50, 0.05);
|
||||
}
|
||||
|
||||
function update() {
|
||||
//game.collide(leftEmitter, rightEmitter);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
+567
-45
@@ -7390,85 +7390,120 @@ var Phaser;
|
||||
})(Phaser || (Phaser = {}));
|
||||
/// <reference path="../_definitions.ts" />
|
||||
/**
|
||||
* Phaser - TimeManager
|
||||
*
|
||||
* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
var TimeManager = (function () {
|
||||
/**
|
||||
* Time constructor
|
||||
* Create a new <code>Time</code>.
|
||||
* This is the core internal game clock. It manages the elapsed time and calculation of delta values,
|
||||
* used for game object motion and tweens.
|
||||
*
|
||||
* @param game {Phaser.Game} Current game instance.
|
||||
* @class TimeManager
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
*/
|
||||
function TimeManager(game) {
|
||||
/**
|
||||
* Elapsed since last frame.
|
||||
* @type {number}
|
||||
* Number of milliseconds elapsed since the last frame update.
|
||||
* @property elapsed
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.elapsed = 0;
|
||||
/**
|
||||
* Game time counter.
|
||||
* @property time
|
||||
* @type {number}
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.time = 0;
|
||||
/**
|
||||
* How long the game has been paused for. Gets reset each time the game pauses.
|
||||
* Records how long the game has been paused for. Is reset each time the game pauses.
|
||||
* @property pausedTime
|
||||
* @type {number}
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.pausedTime = 0;
|
||||
/**
|
||||
* Time of current frame.
|
||||
* The time right now.
|
||||
* @property now
|
||||
* @type {number}
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.now = 0;
|
||||
/**
|
||||
* Elapsed time since last frame.
|
||||
* Elapsed time since the last frame.
|
||||
* @property delta
|
||||
* @type {number}
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.delta = 0;
|
||||
/**
|
||||
* Frames per second.
|
||||
* @type {number}
|
||||
* @property fps
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.fps = 0;
|
||||
/**
|
||||
* Minimal fps.
|
||||
* @type {number}
|
||||
* The lowest rate the fps has dropped to.
|
||||
* @property fpsMin
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.fpsMin = 1000;
|
||||
/**
|
||||
* Maximal fps.
|
||||
* @type {number}
|
||||
* The highest rate the fps has reached (usually no higher than 60fps).
|
||||
* @property fpsMax
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.fpsMax = 0;
|
||||
/**
|
||||
* Minimum duration between 2 frames.
|
||||
* @type {number}
|
||||
* The minimum amount of time the game has taken between two frames.
|
||||
* @property msMin
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.msMin = 1000;
|
||||
/**
|
||||
* Maximum duration between 2 frames.
|
||||
* @type {number}
|
||||
* The maximum amount of time the game has taken between two frames.
|
||||
* @property msMax
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.msMax = 0;
|
||||
/**
|
||||
* How many frames in last second.
|
||||
* @type {number}
|
||||
* The number of frames record in the last second.
|
||||
* @property frames
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.frames = 0;
|
||||
/**
|
||||
* Time of last second.
|
||||
* @type {number}
|
||||
* The time (in ms) that the last second counter ticked over.
|
||||
* @property _timeLastSecond
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
this._timeLastSecond = 0;
|
||||
/**
|
||||
* Records how long the game was paused for in miliseconds.
|
||||
* @property pauseDuration
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.pauseDuration = 0;
|
||||
/**
|
||||
* The time the game started being paused.
|
||||
* @property _pauseStarted
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
this._pauseStarted = 0;
|
||||
this.game = game;
|
||||
|
||||
@@ -7481,7 +7516,7 @@ var Phaser;
|
||||
}
|
||||
Object.defineProperty(TimeManager.prototype, "totalElapsedSeconds", {
|
||||
get: /**
|
||||
*
|
||||
* The number of seconds that have elapsed since the game was started.
|
||||
* @method totalElapsedSeconds
|
||||
* @return {Number}
|
||||
*/
|
||||
@@ -7496,7 +7531,7 @@ var Phaser;
|
||||
* Update clock and calculate the fps.
|
||||
* This is called automatically by Game._raf
|
||||
* @method update
|
||||
* @param {number} raf The current timestamp, either performance.now or Date.now
|
||||
* @param {Number} raf The current timestamp, either performance.now or Date.now
|
||||
*/
|
||||
TimeManager.prototype.update = function (raf) {
|
||||
this.now = raf;
|
||||
@@ -7523,20 +7558,30 @@ var Phaser;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the game enters a paused state.
|
||||
* @method gamePaused
|
||||
* @private
|
||||
*/
|
||||
TimeManager.prototype.gamePaused = function () {
|
||||
this._pauseStarted = this.now;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when the game resumes from a paused state.
|
||||
* @method gameResumed
|
||||
* @private
|
||||
*/
|
||||
TimeManager.prototype.gameResumed = function () {
|
||||
// Level out the delta timer to avoid spikes
|
||||
this.pauseDuration = this.pausedTime;
|
||||
};
|
||||
|
||||
/**
|
||||
* How long has passed since given time.
|
||||
* How long has passed since the given time.
|
||||
* @method elapsedSince
|
||||
* @param {number} since The time you want to measure.
|
||||
* @return {number} Duration between given time and now.
|
||||
* @param {Number} since The time you want to measure against.
|
||||
* @return {Number} The difference between the given time and now.
|
||||
*/
|
||||
TimeManager.prototype.elapsedSince = function (since) {
|
||||
return this.now - since;
|
||||
@@ -7545,15 +7590,15 @@ var Phaser;
|
||||
/**
|
||||
* How long has passed since the given time (in seconds).
|
||||
* @method elapsedSecondsSince
|
||||
* @param {number} since The time you want to measure (in seconds).
|
||||
* @return {number} Duration between given time and now (in seconds).
|
||||
* @param {Number} since The time you want to measure (in seconds).
|
||||
* @return {Number} Duration between given time and now (in seconds).
|
||||
*/
|
||||
TimeManager.prototype.elapsedSecondsSince = function (since) {
|
||||
return (this.now - since) * 0.001;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the start time to now.
|
||||
* Resets the private _started value to now.
|
||||
* @method reset
|
||||
*/
|
||||
TimeManager.prototype.reset = function () {
|
||||
@@ -7818,6 +7863,110 @@ var Phaser;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Keyboard.A = "A".charCodeAt(0);
|
||||
Keyboard.B = "B".charCodeAt(0);
|
||||
Keyboard.C = "C".charCodeAt(0);
|
||||
Keyboard.D = "D".charCodeAt(0);
|
||||
Keyboard.E = "E".charCodeAt(0);
|
||||
Keyboard.F = "F".charCodeAt(0);
|
||||
Keyboard.G = "G".charCodeAt(0);
|
||||
Keyboard.H = "H".charCodeAt(0);
|
||||
Keyboard.I = "I".charCodeAt(0);
|
||||
Keyboard.J = "J".charCodeAt(0);
|
||||
Keyboard.K = "K".charCodeAt(0);
|
||||
Keyboard.L = "L".charCodeAt(0);
|
||||
Keyboard.M = "M".charCodeAt(0);
|
||||
Keyboard.N = "N".charCodeAt(0);
|
||||
Keyboard.O = "O".charCodeAt(0);
|
||||
Keyboard.P = "P".charCodeAt(0);
|
||||
Keyboard.Q = "Q".charCodeAt(0);
|
||||
Keyboard.R = "R".charCodeAt(0);
|
||||
Keyboard.S = "S".charCodeAt(0);
|
||||
Keyboard.T = "T".charCodeAt(0);
|
||||
Keyboard.U = "U".charCodeAt(0);
|
||||
Keyboard.V = "V".charCodeAt(0);
|
||||
Keyboard.W = "W".charCodeAt(0);
|
||||
Keyboard.X = "X".charCodeAt(0);
|
||||
Keyboard.Y = "Y".charCodeAt(0);
|
||||
Keyboard.Z = "Z".charCodeAt(0);
|
||||
|
||||
Keyboard.ZERO = "0".charCodeAt(0);
|
||||
Keyboard.ONE = "1".charCodeAt(0);
|
||||
Keyboard.TWO = "2".charCodeAt(0);
|
||||
Keyboard.THREE = "3".charCodeAt(0);
|
||||
Keyboard.FOUR = "4".charCodeAt(0);
|
||||
Keyboard.FIVE = "5".charCodeAt(0);
|
||||
Keyboard.SIX = "6".charCodeAt(0);
|
||||
Keyboard.SEVEN = "7".charCodeAt(0);
|
||||
Keyboard.EIGHT = "8".charCodeAt(0);
|
||||
Keyboard.NINE = "9".charCodeAt(0);
|
||||
|
||||
Keyboard.NUMPAD_0 = 96;
|
||||
Keyboard.NUMPAD_1 = 97;
|
||||
Keyboard.NUMPAD_2 = 98;
|
||||
Keyboard.NUMPAD_3 = 99;
|
||||
Keyboard.NUMPAD_4 = 100;
|
||||
Keyboard.NUMPAD_5 = 101;
|
||||
Keyboard.NUMPAD_6 = 102;
|
||||
Keyboard.NUMPAD_7 = 103;
|
||||
Keyboard.NUMPAD_8 = 104;
|
||||
Keyboard.NUMPAD_9 = 105;
|
||||
Keyboard.NUMPAD_MULTIPLY = 106;
|
||||
Keyboard.NUMPAD_ADD = 107;
|
||||
Keyboard.NUMPAD_ENTER = 108;
|
||||
Keyboard.NUMPAD_SUBTRACT = 109;
|
||||
Keyboard.NUMPAD_DECIMAL = 110;
|
||||
Keyboard.NUMPAD_DIVIDE = 111;
|
||||
|
||||
Keyboard.F1 = 112;
|
||||
Keyboard.F2 = 113;
|
||||
Keyboard.F3 = 114;
|
||||
Keyboard.F4 = 115;
|
||||
Keyboard.F5 = 116;
|
||||
Keyboard.F6 = 117;
|
||||
Keyboard.F7 = 118;
|
||||
Keyboard.F8 = 119;
|
||||
Keyboard.F9 = 120;
|
||||
Keyboard.F10 = 121;
|
||||
Keyboard.F11 = 122;
|
||||
Keyboard.F12 = 123;
|
||||
Keyboard.F13 = 124;
|
||||
Keyboard.F14 = 125;
|
||||
Keyboard.F15 = 126;
|
||||
|
||||
Keyboard.COLON = 186;
|
||||
Keyboard.EQUALS = 187;
|
||||
Keyboard.UNDERSCORE = 189;
|
||||
Keyboard.QUESTION_MARK = 191;
|
||||
Keyboard.TILDE = 192;
|
||||
Keyboard.OPEN_BRACKET = 219;
|
||||
Keyboard.BACKWARD_SLASH = 220;
|
||||
Keyboard.CLOSED_BRACKET = 221;
|
||||
Keyboard.QUOTES = 222;
|
||||
|
||||
Keyboard.BACKSPACE = 8;
|
||||
Keyboard.TAB = 9;
|
||||
Keyboard.CLEAR = 12;
|
||||
Keyboard.ENTER = 13;
|
||||
Keyboard.SHIFT = 16;
|
||||
Keyboard.CONTROL = 17;
|
||||
Keyboard.ALT = 18;
|
||||
Keyboard.CAPS_LOCK = 20;
|
||||
Keyboard.ESC = 27;
|
||||
Keyboard.SPACEBAR = 32;
|
||||
Keyboard.PAGE_UP = 33;
|
||||
Keyboard.PAGE_DOWN = 34;
|
||||
Keyboard.END = 35;
|
||||
Keyboard.HOME = 36;
|
||||
Keyboard.LEFT = 37;
|
||||
Keyboard.UP = 38;
|
||||
Keyboard.RIGHT = 39;
|
||||
Keyboard.DOWN = 40;
|
||||
Keyboard.INSERT = 45;
|
||||
Keyboard.DELETE = 46;
|
||||
Keyboard.HELP = 47;
|
||||
Keyboard.NUM_LOCK = 144;
|
||||
return Keyboard;
|
||||
})();
|
||||
Phaser.Keyboard = Keyboard;
|
||||
@@ -15737,9 +15886,10 @@ var Phaser;
|
||||
*
|
||||
* @return {Particle} The newly created particle object.
|
||||
*/
|
||||
//public particle(): ArcadeParticle {
|
||||
// return new ArcadeParticle(this.game);
|
||||
//}
|
||||
GameObjectFactory.prototype.particle = function () {
|
||||
return new Phaser.ArcadeParticle(this.game);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new Emitter.
|
||||
*
|
||||
@@ -15748,9 +15898,13 @@ var Phaser;
|
||||
* @param size {number} Optional, size of this emitter.
|
||||
* @return {Emitter} The newly created emitter object.
|
||||
*/
|
||||
//public emitter(x: number = 0, y: number = 0, size: number = 0): ArcadeEmitter {
|
||||
// return <ArcadeEmitter> this._world.group.add(new ArcadeEmitter(this.game, x, y, size));
|
||||
//}
|
||||
GameObjectFactory.prototype.emitter = function (x, y, size) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof size === "undefined") { size = 0; }
|
||||
return this._world.group.add(new Phaser.ArcadeEmitter(this.game, x, y, size));
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new ScrollZone object with image key, position and size.
|
||||
*
|
||||
@@ -15849,9 +16003,10 @@ var Phaser;
|
||||
* @param emitter The Emitter to add to the Game World
|
||||
* @return {Phaser.Emitter} The Emitter object
|
||||
*/
|
||||
//public existingEmitter(emitter: ArcadeEmitter): ArcadeEmitter {
|
||||
// return this._world.group.add(emitter);
|
||||
//}
|
||||
GameObjectFactory.prototype.existingEmitter = function (emitter) {
|
||||
return this._world.group.add(emitter);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an existing ScrollZone to the current world.
|
||||
* Note: This doesn't check or update the objects reference to Game. If that is wrong, all kinds of things will break.
|
||||
@@ -15888,6 +16043,373 @@ var Phaser;
|
||||
})();
|
||||
Phaser.GameObjectFactory = GameObjectFactory;
|
||||
})(Phaser || (Phaser = {}));
|
||||
/// <reference path="../_definitions.ts" />
|
||||
/**
|
||||
* Phaser - ArcadeEmitter
|
||||
*
|
||||
* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
|
||||
* continuous effects like rain and fire. All it really does is launch Particle objects out
|
||||
* at set intervals, and fixes their positions and velocities accorindgly.
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
var ArcadeEmitter = (function (_super) {
|
||||
__extends(ArcadeEmitter, _super);
|
||||
/**
|
||||
* Creates a new <code>Emitter</code> object at a specific position.
|
||||
* Does NOT automatically generate or attach particles!
|
||||
*
|
||||
* @param x {number} The X position of the emitter.
|
||||
* @param y {number} The Y position of the emitter.
|
||||
* @param [size] {number} Specifies a maximum capacity for this emitter.
|
||||
*/
|
||||
function ArcadeEmitter(game, x, y, size) {
|
||||
if (typeof x === "undefined") { x = 0; }
|
||||
if (typeof y === "undefined") { y = 0; }
|
||||
if (typeof size === "undefined") { size = 0; }
|
||||
_super.call(this, game, size);
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = 0;
|
||||
this.height = 0;
|
||||
this.minParticleSpeed = new Phaser.Vec2(-100, -100);
|
||||
this.maxParticleSpeed = new Phaser.Vec2(100, 100);
|
||||
this.minRotation = -360;
|
||||
this.maxRotation = 360;
|
||||
this.gravity = 0;
|
||||
this.particleClass = null;
|
||||
this.particleDrag = new Phaser.Vec2();
|
||||
this.frequency = 0.1;
|
||||
this.lifespan = 3;
|
||||
this.bounce = 0;
|
||||
this._quantity = 0;
|
||||
this._counter = 0;
|
||||
this._explode = true;
|
||||
this.on = false;
|
||||
|
||||
this.exists = true;
|
||||
this.active = true;
|
||||
this.visible = true;
|
||||
}
|
||||
/**
|
||||
* Clean up memory.
|
||||
*/
|
||||
ArcadeEmitter.prototype.destroy = function () {
|
||||
this.minParticleSpeed = null;
|
||||
this.maxParticleSpeed = null;
|
||||
this.particleDrag = null;
|
||||
this.particleClass = null;
|
||||
this._point = null;
|
||||
_super.prototype.destroy.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* This function generates a new array of particle sprites to attach to the emitter.
|
||||
*
|
||||
* @param graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet.
|
||||
* @param quantity {number} The number of particles to generate when using the "create from image" option.
|
||||
* @param multiple {boolean} Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).
|
||||
* @param collide {number} Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.
|
||||
*
|
||||
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
|
||||
*/
|
||||
ArcadeEmitter.prototype.makeParticles = function (graphics, quantity, multiple, collide) {
|
||||
if (typeof quantity === "undefined") { quantity = 50; }
|
||||
if (typeof multiple === "undefined") { multiple = false; }
|
||||
if (typeof collide === "undefined") { collide = 0; }
|
||||
this.maxSize = quantity;
|
||||
|
||||
var totalFrames = 1;
|
||||
|
||||
/*
|
||||
if(Multiple)
|
||||
{
|
||||
var sprite:Sprite = new Sprite(this.game);
|
||||
sprite.loadGraphic(Graphics,true);
|
||||
totalFrames = sprite.frames;
|
||||
sprite.destroy();
|
||||
}
|
||||
*/
|
||||
var randomFrame;
|
||||
var particle;
|
||||
var i = 0;
|
||||
|
||||
while (i < quantity) {
|
||||
if (this.particleClass == null) {
|
||||
particle = new Phaser.ArcadeParticle(this.game);
|
||||
} else {
|
||||
particle = new this.particleClass(this.game);
|
||||
}
|
||||
|
||||
if (multiple) {
|
||||
/*
|
||||
randomFrame = this.game.math.random()*totalFrames;
|
||||
*/
|
||||
} else {
|
||||
if (graphics) {
|
||||
particle.texture.loadImage(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
if (collide > 0) {
|
||||
//particle.body.allowCollisions = Types.ANY;
|
||||
particle.body.type = Phaser.Types.BODY_DYNAMIC;
|
||||
particle.width *= collide;
|
||||
particle.height *= collide;
|
||||
} else {
|
||||
//particle.body.allowCollisions = Types.NONE;
|
||||
}
|
||||
|
||||
particle.exists = false;
|
||||
|
||||
// Center the origin for rotation assistance
|
||||
//particle.transform.origin.setTo(particle.body.bounds.halfWidth, particle.body.bounds.halfHeight);
|
||||
this.add(particle);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
ArcadeEmitter.prototype.preUpdate = function () {
|
||||
};
|
||||
ArcadeEmitter.prototype.postUpdate = function () {
|
||||
};
|
||||
|
||||
/**
|
||||
* Called automatically by the game loop, decides when to launch particles and when to "die".
|
||||
*/
|
||||
ArcadeEmitter.prototype.update = function () {
|
||||
if (this.on) {
|
||||
if (this._explode) {
|
||||
this.on = false;
|
||||
|
||||
var i = 0;
|
||||
var l = this._quantity;
|
||||
|
||||
if ((l <= 0) || (l > this.length)) {
|
||||
l = this.length;
|
||||
}
|
||||
|
||||
while (i < l) {
|
||||
this.emitParticle();
|
||||
i++;
|
||||
}
|
||||
|
||||
this._quantity = 0;
|
||||
} else {
|
||||
this._timer += this.game.time.elapsed;
|
||||
|
||||
while ((this.frequency > 0) && (this._timer > this.frequency) && this.on) {
|
||||
this._timer -= this.frequency;
|
||||
this.emitParticle();
|
||||
|
||||
if ((this._quantity > 0) && (++this._counter >= this._quantity)) {
|
||||
this.on = false;
|
||||
this._quantity = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_super.prototype.update.call(this);
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to turn off all the particles and the emitter.
|
||||
*/
|
||||
ArcadeEmitter.prototype.kill = function () {
|
||||
this.on = false;
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
|
||||
* In practice, this is most often called by <code>Object.reset()</code>.
|
||||
*/
|
||||
ArcadeEmitter.prototype.revive = function () {
|
||||
this.alive = true;
|
||||
this.exists = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Call this function to start emitting particles.
|
||||
*
|
||||
* @param explode {boolean} Whether the particles should all burst out at once.
|
||||
* @param lifespan {number} How long each particle lives once emitted. 0 = forever.
|
||||
* @param frequency {number} Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.
|
||||
* @param quantity {number} How many particles to launch. 0 = "all of the particles".
|
||||
*/
|
||||
ArcadeEmitter.prototype.start = function (explode, lifespan, frequency, quantity) {
|
||||
if (typeof explode === "undefined") { explode = true; }
|
||||
if (typeof lifespan === "undefined") { lifespan = 0; }
|
||||
if (typeof frequency === "undefined") { frequency = 0.1; }
|
||||
if (typeof quantity === "undefined") { quantity = 0; }
|
||||
this.revive();
|
||||
|
||||
this.visible = true;
|
||||
this.on = true;
|
||||
|
||||
this._explode = explode;
|
||||
this.lifespan = lifespan;
|
||||
this.frequency = frequency;
|
||||
this._quantity += quantity;
|
||||
|
||||
this._counter = 0;
|
||||
this._timer = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* This function can be used both internally and externally to emit the next particle.
|
||||
*/
|
||||
ArcadeEmitter.prototype.emitParticle = function () {
|
||||
var particle = this.recycle(Phaser.ArcadeParticle);
|
||||
|
||||
particle.lifespan = this.lifespan;
|
||||
|
||||
//particle.body.bounce.setTo(this.bounce, this.bounce);
|
||||
Phaser.SpriteUtils.reset(particle, this.x - (particle.width >> 1) + this.game.rnd.integer * this.width, this.y - (particle.height >> 1) + this.game.rnd.integer * this.height);
|
||||
particle.visible = true;
|
||||
|
||||
if (this.minParticleSpeed.x != this.maxParticleSpeed.x) {
|
||||
particle.body.velocity.x = this.minParticleSpeed.x + this.game.rnd.integer * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
|
||||
} else {
|
||||
particle.body.velocity.x = this.minParticleSpeed.x;
|
||||
}
|
||||
|
||||
if (this.minParticleSpeed.y != this.maxParticleSpeed.y) {
|
||||
particle.body.velocity.y = this.minParticleSpeed.y + this.game.rnd.integer * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
|
||||
} else {
|
||||
particle.body.velocity.y = this.minParticleSpeed.y;
|
||||
}
|
||||
|
||||
if (this.minRotation != this.maxRotation && this.minRotation !== 0 && this.maxRotation !== 0) {
|
||||
particle.body.angularVelocity = this.minRotation + this.game.rnd.integer * (this.maxRotation - this.minRotation);
|
||||
} else {
|
||||
particle.body.angularVelocity = this.minRotation;
|
||||
}
|
||||
|
||||
if (particle.body.angularVelocity != 0) {
|
||||
particle.rotation = this.game.rnd.integer * 360 - 180;
|
||||
}
|
||||
|
||||
//particle.body.drag.x = this.particleDrag.x;
|
||||
//particle.body.drag.y = this.particleDrag.y;
|
||||
particle.onEmit();
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the width and height of the emitter.
|
||||
*
|
||||
* @param width {number} The desired width of the emitter (particles are spawned randomly within these dimensions).
|
||||
* @param height {number} The desired height of the emitter.
|
||||
*/
|
||||
ArcadeEmitter.prototype.setSize = function (width, height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the X velocity range of the emitter.
|
||||
*
|
||||
* @param Min {number} The minimum value for this range.
|
||||
* @param Max {number} The maximum value for this range.
|
||||
*/
|
||||
ArcadeEmitter.prototype.setXSpeed = function (min, max) {
|
||||
if (typeof min === "undefined") { min = 0; }
|
||||
if (typeof max === "undefined") { max = 0; }
|
||||
this.minParticleSpeed.x = min;
|
||||
this.maxParticleSpeed.x = max;
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the Y velocity range of the emitter.
|
||||
*
|
||||
* @param Min {number} The minimum value for this range.
|
||||
* @param Max {number} The maximum value for this range.
|
||||
*/
|
||||
ArcadeEmitter.prototype.setYSpeed = function (min, max) {
|
||||
if (typeof min === "undefined") { min = 0; }
|
||||
if (typeof max === "undefined") { max = 0; }
|
||||
this.minParticleSpeed.y = min;
|
||||
this.maxParticleSpeed.y = max;
|
||||
};
|
||||
|
||||
/**
|
||||
* A more compact way of setting the angular velocity constraints of the emitter.
|
||||
*
|
||||
* @param Min {number} The minimum value for this range.
|
||||
* @param Max {number} The maximum value for this range.
|
||||
*/
|
||||
ArcadeEmitter.prototype.setRotation = function (min, max) {
|
||||
if (typeof min === "undefined") { min = 0; }
|
||||
if (typeof max === "undefined") { max = 0; }
|
||||
this.minRotation = min;
|
||||
this.maxRotation = max;
|
||||
};
|
||||
|
||||
/**
|
||||
* Change the emitter's midpoint to match the midpoint of a <code>Object</code>.
|
||||
*
|
||||
* @param Object {object} The <code>Object</code> that you want to sync up with.
|
||||
*/
|
||||
ArcadeEmitter.prototype.at = function (object) {
|
||||
//this.x = object.body.bounds.halfWidth - (this.width >> 1);
|
||||
//this.y = object.body.bounds.halfHeight - (this.height >> 1);
|
||||
};
|
||||
return ArcadeEmitter;
|
||||
})(Phaser.Group);
|
||||
Phaser.ArcadeEmitter = ArcadeEmitter;
|
||||
})(Phaser || (Phaser = {}));
|
||||
/// <reference path="../_definitions.ts" />
|
||||
/**
|
||||
* Phaser - ArcadeParticle
|
||||
*
|
||||
* This is a simple particle class that extends a Sprite to have a slightly more
|
||||
* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required.
|
||||
*/
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
var ArcadeParticle = (function (_super) {
|
||||
__extends(ArcadeParticle, _super);
|
||||
/**
|
||||
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
|
||||
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
|
||||
*/
|
||||
function ArcadeParticle(game) {
|
||||
_super.call(this, game);
|
||||
|
||||
this.body.type = Phaser.Types.BODY_DYNAMIC;
|
||||
this.lifespan = 0;
|
||||
}
|
||||
/**
|
||||
* The particle's main update logic. Basically it checks to see if it should be dead yet.
|
||||
*/
|
||||
ArcadeParticle.prototype.update = function () {
|
||||
if (this.lifespan <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.lifespan -= this.game.time.elapsed;
|
||||
|
||||
if (this.lifespan <= 0) {
|
||||
this.kill();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Triggered whenever this object is launched by a <code>Emitter</code>.
|
||||
* You can override this to add custom behavior like a sound or AI or something.
|
||||
*/
|
||||
ArcadeParticle.prototype.onEmit = function () {
|
||||
};
|
||||
return ArcadeParticle;
|
||||
})(Phaser.Sprite);
|
||||
Phaser.ArcadeParticle = ArcadeParticle;
|
||||
})(Phaser || (Phaser = {}));
|
||||
var Phaser;
|
||||
(function (Phaser) {
|
||||
/// <reference path="../_definitions.ts" />
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('balls', 'assets/sprites/balls.png');
|
||||
}
|
||||
|
||||
var scroller;
|
||||
|
||||
function create() {
|
||||
// The source image (balls.png) is only 102x17 in size, but we want it to create a scroll the size of the whole game window.
|
||||
// We can take advantage of the way a ScrollZone can create a seamless pattern for us automatically.
|
||||
@@ -13,9 +16,11 @@
|
||||
// for rendering.
|
||||
// We've rounded the height up to 612 because in order to have a seamless pattern it needs to be a multiple of 17 (the height of the source image)
|
||||
scroller = game.add.scrollZone('balls', 0, 0, 800, 612);
|
||||
|
||||
// Some sin/cos data for the movement
|
||||
game.math.sinCosGenerator(256, 4, 4, 2);
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Cycle through the wave data and apply it to the scroll speed (causes the circular wave motion)
|
||||
scroller.currentRegion.scrollSpeed.x = game.math.shiftSinTable();
|
||||
|
||||
@@ -1,101 +1,123 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
game.load.image('nashwan', 'assets/sprites/xenon2_ship.png');
|
||||
game.load.image('starfield', 'assets/misc/starfield.jpg');
|
||||
game.load.image('jet', 'assets/sprites/particle1.png');
|
||||
game.load.image('bullet', 'assets/misc/bullet1.png');
|
||||
}
|
||||
|
||||
var scroller;
|
||||
var emitter;
|
||||
var ship;
|
||||
var bullets;
|
||||
|
||||
var speed = 0;
|
||||
var fireRate = 0;
|
||||
var shipMotion;
|
||||
|
||||
function create() {
|
||||
scroller = game.add.scrollZone('starfield', 0, 0, 1024, 1024);
|
||||
|
||||
emitter = game.add.emitter(game.stage.centerX + 16, game.stage.centerY + 12);
|
||||
emitter.makeParticles('jet', 250, false, 0);
|
||||
emitter.setRotation(0, 0);
|
||||
|
||||
// Looks like a smoke trail!
|
||||
//emitter.globalCompositeOperation = 'xor';
|
||||
// Looks way cool :)
|
||||
emitter.texture.globalCompositeOperation = 'lighter';
|
||||
|
||||
bullets = game.add.group(50);
|
||||
// Create our bullet pool
|
||||
for(var i = 0; i < 50; i++) {
|
||||
|
||||
for (var i = 0; i < 50; i++) {
|
||||
var tempBullet = new Phaser.Sprite(game, game.stage.centerX, game.stage.centerY, 'bullet');
|
||||
tempBullet.exists = false;
|
||||
tempBullet.transform.rotationOffset = 90;
|
||||
|
||||
//tempBullet.setBounds(-100, -100, 900, 700);
|
||||
//tempBullet.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
|
||||
bullets.add(tempBullet);
|
||||
}
|
||||
|
||||
ship = game.add.sprite(game.stage.centerX, game.stage.centerY, 'nashwan', Phaser.Types.BODY_DYNAMIC);
|
||||
ship.transform.origin.setTo(0.5, 0.5);
|
||||
|
||||
// We do this because the ship was drawn facing up, but 0 degrees is pointing to the right
|
||||
ship.transform.rotationOffset = 90;
|
||||
|
||||
game.input.onDown.add(test, this);
|
||||
}
|
||||
|
||||
function test(event) {
|
||||
game.stage.scale.startFullScreen();
|
||||
}
|
||||
|
||||
function update() {
|
||||
ship.body.angularVelocity = 0;
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
ship.body.angularVelocity = -200;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
ship.body.angularVelocity = 200;
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
speed += 0.1;
|
||||
if(speed > 10) {
|
||||
|
||||
if (speed > 10) {
|
||||
speed = 10;
|
||||
}
|
||||
} else {
|
||||
speed -= 0.1;
|
||||
if(speed < 0) {
|
||||
|
||||
if (speed < 0) {
|
||||
speed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//shipMotion = game.motion.velocityFromAngle(ship.rotation, speed);
|
||||
scroller.setSpeed(shipMotion.x, shipMotion.y);
|
||||
// emit particles
|
||||
if(speed > 2) {
|
||||
|
||||
if (speed > 2) {
|
||||
// We use the opposite of the motion because the jets emit out the back of the ship
|
||||
// The 20 and 30 values just keep them nice and fast
|
||||
emitter.setXSpeed(-(shipMotion.x * 20), -(shipMotion.x * 30));
|
||||
emitter.setYSpeed(-(shipMotion.y * 20), -(shipMotion.y * 30));
|
||||
emitter.emitParticle();
|
||||
}
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) {
|
||||
fire();
|
||||
}
|
||||
}
|
||||
|
||||
function render() {
|
||||
//ship.body.renderDebugInfo(32, 32);
|
||||
}
|
||||
}
|
||||
|
||||
function recycleBullet(bullet) {
|
||||
if(bullet.exists && bullet.x < -40 || bullet.x > 840 || bullet.y < -40 || bullet.y > 640) {
|
||||
if (bullet.exists && bullet.x < -40 || bullet.x > 840 || bullet.y < -40 || bullet.y > 640) {
|
||||
bullet.exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
function fire() {
|
||||
if(game.time.now > fireRate) {
|
||||
if (game.time.now > fireRate) {
|
||||
var b = bullets.getFirstAvailable();
|
||||
|
||||
b.x = ship.x;
|
||||
b.y = ship.y - 26;
|
||||
|
||||
//var bulletMotion = game.motion.velocityFromAngle(ship.rotation, 400);
|
||||
var bulletMotion = {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
var bulletMotion = { x: 0, y: 0 };
|
||||
|
||||
b.revive();
|
||||
b.rotation = ship.rotation;
|
||||
b.body.velocity.setTo(bulletMotion.x, bulletMotion.y);
|
||||
|
||||
fireRate = game.time.now + 100;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
@@ -12,8 +11,6 @@
|
||||
game.load.image('jet', 'assets/sprites/particle1.png');
|
||||
game.load.image('bullet', 'assets/misc/bullet1.png');
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
var scroller: Phaser.ScrollZone;
|
||||
|
||||
@@ -2,24 +2,30 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('starray', 'assets/pics/auto_scroll_landscape.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
var zone = game.add.scrollZone('starray');
|
||||
|
||||
// Hide the default region (the full image)
|
||||
zone.currentRegion.visible = false;
|
||||
|
||||
var y = 0;
|
||||
var speed = 16;
|
||||
// The image consists of 10px high scrolling layers, this creates them quickly (top = fastest, getting slower as we move down)
|
||||
for(var z = 0; z < 32; z++) {
|
||||
|
||||
for (var z = 0; z < 32; z++) {
|
||||
zone.addRegion(0, y, 640, 10, speed);
|
||||
if(z <= 15) {
|
||||
|
||||
if (z <= 15) {
|
||||
speed -= 1;
|
||||
} else {
|
||||
speed += 1;
|
||||
}
|
||||
if(z == 15) {
|
||||
|
||||
if (z == 15) {
|
||||
y = 240;
|
||||
speed += 1;
|
||||
} else {
|
||||
|
||||
@@ -2,19 +2,25 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('angelDawn', 'assets/pics/game14_angel_dawn.png');
|
||||
}
|
||||
|
||||
var scroller;
|
||||
|
||||
function create() {
|
||||
// This creates our ScrollZone centered in the middle of the stage.
|
||||
scroller = game.add.scrollZone('angelDawn', game.stage.centerX - 320, 100);
|
||||
|
||||
// By default we won't scroll the full image, but we will create 3 ScrollRegions within it:
|
||||
// This creates a ScrollRegion which can be thought of as a rectangle within the ScrollZone that can be scrolled
|
||||
// independantly - this one scrolls the image of the spacemans head
|
||||
scroller.addRegion(32, 32, 352, 240, 0, 2);
|
||||
|
||||
// The head in the top right
|
||||
scroller.addRegion(480, 30, 96, 96, 4, 0);
|
||||
|
||||
// The small piece of text
|
||||
scroller.addRegion(466, 160, 122, 14, 0, -0.5);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,21 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('dragonsun', 'assets/pics/cougar_dragonsun.png');
|
||||
game.load.image('overlay', 'assets/pics/scrollframe.png');
|
||||
}
|
||||
|
||||
var scroller;
|
||||
|
||||
function create() {
|
||||
// This creates our ScrollZone. It is positioned at x32 y32 (world coodinates)
|
||||
// and is a size of 352x240 (which matches the window in our overlay image)
|
||||
scroller = game.add.scrollZone('dragonsun', 32, 32, 352, 240);
|
||||
|
||||
scroller.setSpeed(2, 2);
|
||||
|
||||
game.add.sprite(0, 0, 'overlay');
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('crystal', 'assets/pics/jim_sachs_time_crystal.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// This creates our ScrollZone. It is positioned at x0 y0 (world coodinates) by default and uses
|
||||
// the 'crystal' image from the cache.
|
||||
|
||||
@@ -2,18 +2,23 @@
|
||||
/// <reference path="../../Phaser/gameobjects/ScrollZone.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
game.load.image('balls', 'assets/sprites/balls.png');
|
||||
}
|
||||
|
||||
var leftFace;
|
||||
var rightFace;
|
||||
var topFace;
|
||||
|
||||
function create() {
|
||||
topFace = game.add.scrollZone('balls', 200, 0, 204, 204).setSpeed(0, 2.2);
|
||||
topFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(-30)));
|
||||
topFace.transform.scale.setTo(1, 1.3);
|
||||
|
||||
leftFace = game.add.scrollZone('balls', 110, 264, 204, 204).setSpeed(0, 2.1);
|
||||
leftFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(30)));
|
||||
|
||||
rightFace = game.add.scrollZone('balls', 200, 466, 204, 204).setSpeed(0, 2);
|
||||
rightFace.transform.skew.setTo(0, Math.tan(game.math.radiansToDegrees(-30)));
|
||||
rightFace.transform.scale.setTo(1, 0.8);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// Here we'll assign the new sprite to the local bunny variable
|
||||
var bunny = game.add.sprite(0, 0, 'bunny');
|
||||
|
||||
// And this sets the alpha of the sprite to 0.5, which is 50% opaque
|
||||
bunny.alpha = 0.5;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,28 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
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');
|
||||
|
||||
// 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.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() {
|
||||
bot.x -= 1;
|
||||
if(bot.x < -bot.width) {
|
||||
|
||||
if (bot.x < -bot.width) {
|
||||
bot.x = game.stage.width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
// The sprite sheet is a standard frame-by-frame sheet, and each frame is 37 x 45 pixels in size.
|
||||
// The final parameter (18) is the number of frames there are. You can omit this if your frames fill the entire sheet.
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
var mummy;
|
||||
|
||||
function create() {
|
||||
mummy = game.add.sprite(game.stage.centerX, game.stage.centerY, 'mummy');
|
||||
|
||||
// Here we add new animation called 'walk'.
|
||||
// As it's the only animation in our sprite sheet we don't need to define the frames being used.
|
||||
mummy.animations.add('walk');
|
||||
|
||||
// This plays the animation at 20 frames per second on a loop (the 3rd parameter)
|
||||
// Try changing the 20 value to something low to slow the speed down, or higher to make it play faster.
|
||||
mummy.animations.play('walk', 20, true);
|
||||
|
||||
// This just scales the sprite up so you can see the animation better
|
||||
mummy.transform.scale.setTo(4, 4);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.spritesheet('monster', 'assets/sprites/metalslug_monster39x40.png', 39, 40);
|
||||
}
|
||||
|
||||
var monster;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(50,10,10)';
|
||||
|
||||
// Notice the use of 'stage.centerX' - this places the sprite in the middle of the stage without needing to do any extra math
|
||||
monster = game.add.sprite(game.stage.centerX, game.stage.centerY, 'monster');
|
||||
|
||||
// For this animation we pass 'null' for the frames, because we're going to use them all
|
||||
// And we set the frame rate (30) and loop status (true) when we add the animation
|
||||
// If the frame rate and looping is never going to change then it's easier to do it here
|
||||
monster.animations.add('walk', null, 30, true);
|
||||
|
||||
// Then you can just call 'play' on its own with no other values to start things going
|
||||
monster.animations.play('walk');
|
||||
|
||||
monster.transform.scale.setTo(2, 2);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// This will create a Sprite positioned at the top-left of the game (0,0)
|
||||
// Try changing the 0, 0 values
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update, render);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('disk', 'assets/sprites/oz_pov_melting_disk.png');
|
||||
@@ -9,15 +10,19 @@
|
||||
game.load.image('fuji3', 'assets/tests/320x200.png');
|
||||
game.load.image('fuji4', 'assets/tests/320x200g.png');
|
||||
}
|
||||
|
||||
var fuji;
|
||||
var fuji2;
|
||||
var fuji3;
|
||||
|
||||
function create() {
|
||||
game.stage.backgroundColor = 'rgb(0,0,0)';
|
||||
|
||||
//game.world.setSize(2000, 1200, true);
|
||||
// The sprite is 320 x 200 pixels in size positioned in the middle of the stage
|
||||
//fuji = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji4');
|
||||
fuji2 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji3');
|
||||
|
||||
//fuji2 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji2');
|
||||
//fuji3 = game.add.sprite(game.stage.centerX, game.stage.centerY, 'fuji2');
|
||||
//fuji.visible = false;
|
||||
@@ -38,31 +43,35 @@
|
||||
//fuji.transform.origin.setTo(0.5, 0.5);
|
||||
//fuji.transform.origin.setTo(0, 0);
|
||||
fuji2.transform.origin.setTo(1, 1);
|
||||
|
||||
//fuji3.transform.origin.setTo(1, 1);
|
||||
game.input.onTap.add(rotateIt, this);
|
||||
//game.stage.clear = false;
|
||||
}
|
||||
}
|
||||
|
||||
function rotateIt() {
|
||||
//fuji.rotation += 10;
|
||||
fuji2.rotation += 10;
|
||||
//fuji3.rotation += 20;
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
//fuji.rotation++;
|
||||
//fuji2.rotation++;
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
var points;
|
||||
var points2;
|
||||
|
||||
function render() {
|
||||
// This = the center point
|
||||
//var cx = fuji2.x + (fuji2.width / 2) * cos - (fuji2.height / 2) * sin;
|
||||
@@ -90,6 +99,7 @@
|
||||
//game.stage.context.fillRect(cx, cy, 4, 4);
|
||||
var sin = Math.sin((fuji2.transform.rotation + fuji2.transform.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
|
||||
var cos = Math.cos((fuji2.transform.rotation + fuji2.transform.rotationOffset) * Phaser.GameMath.DEG_TO_RAD);
|
||||
|
||||
var originX = fuji2.transform.origin.x * fuji2.width;
|
||||
var originY = fuji2.transform.origin.y * fuji2.height;
|
||||
var centerX = 0.5 * fuji2.width;
|
||||
@@ -97,8 +107,10 @@
|
||||
var distanceX = originX - centerX;
|
||||
var distanceY = originY - centerY;
|
||||
var distance = Math.sqrt(((originX - centerX) * (originX - centerX)) + ((originY - centerY) * (originY - centerY)));
|
||||
|
||||
var px = fuji2.x + distance * Math.cos(fuji2.transform.rotation + 45 * Math.PI / 180);
|
||||
var py = fuji2.y + distance * Math.sin(fuji2.transform.rotation + 45 * Math.PI / 180);
|
||||
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgb(255,255,0)';
|
||||
game.stage.context.fillText('rect width: ' + originX + ' height: ' + originY, 32, 32);
|
||||
@@ -107,6 +119,7 @@
|
||||
game.stage.context.fillText('point of rotation x: ' + fuji2.transform.origin.x + ' y: ' + fuji2.transform.origin.y, 32, 92);
|
||||
game.stage.context.fillText('x: ' + fuji2.x + ' y: ' + fuji2.y, fuji2.x + 4, fuji2.y);
|
||||
game.stage.context.restore();
|
||||
|
||||
game.stage.context.save();
|
||||
game.stage.context.fillStyle = 'rgba(255,255,255,0.1)';
|
||||
game.stage.context.arc(fuji2.x, fuji2.y, distance, 0, Math.PI * 2);
|
||||
@@ -224,5 +237,5 @@
|
||||
*/
|
||||
//game.stage.context.strokeStyle = 'rgb(255,255,0)';
|
||||
//game.stage.context.strokeRect(fuji.cameraView.x, fuji.cameraView.y, fuji.cameraView.width, fuji.cameraView.height);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
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 by half
|
||||
// You can do either:
|
||||
//smallBunny.scale.x = 0.5;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
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.transform.scale.x = 2;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
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.transform.scale.setTo(3, 0.7);
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
bunny.transform.scale.setTo(0.5, 0.5);
|
||||
|
||||
// This time let's scale the sprite by a looped tween
|
||||
game.add.tween(bunny.transform.scale).to({
|
||||
x: 1.5,
|
||||
y: 1.5
|
||||
}, 2000, Phaser.Easing.Elastic.Out, true, 0, true, true);
|
||||
game.add.tween(bunny.transform.scale).to({ x: 1.5, y: 1.5 }, 2000, Phaser.Easing.Elastic.Out, true, 0, true, true);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,40 +1,46 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
}
|
||||
|
||||
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, game.stage.centerY, 'fuji');
|
||||
|
||||
// sets origin to the center of the sprite (half the width and half the height)
|
||||
fuji.transform.origin.setTo(0.5, 0.5);
|
||||
|
||||
// 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.transform.scale);
|
||||
|
||||
// Start it going
|
||||
scaleLeft();
|
||||
}
|
||||
|
||||
function scaleLeft() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 0
|
||||
}, 1000);
|
||||
tween.to({ x: 0 }, 1000);
|
||||
tween.onComplete.add(scaleRight, this);
|
||||
tween.start();
|
||||
}
|
||||
|
||||
function scaleRight() {
|
||||
tween.clear();
|
||||
tween.to({
|
||||
x: 1
|
||||
}, 1000);
|
||||
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,19 +1,22 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
}
|
||||
|
||||
var fuji;
|
||||
|
||||
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, game.stage.centerY, 'fuji');
|
||||
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
// If we don't set an origin then the sprite will rotate around 0,0 - the top left corner
|
||||
game.add.tween(fuji).to({
|
||||
rotation: 360
|
||||
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
}
|
||||
|
||||
var fuji;
|
||||
|
||||
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, game.stage.centerY, 'fuji');
|
||||
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
// Here we set the origin to the center of the sprite (half of its width and height, so 160x100)
|
||||
// This will cause it to rotate on its center
|
||||
fuji.transform.origin.setTo(0.5, 0.5);
|
||||
game.add.tween(fuji).to({
|
||||
rotation: 360
|
||||
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
|
||||
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
}
|
||||
|
||||
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, game.stage.centerY, 'fuji');
|
||||
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
// Here we set the origin to be the bottom-right of the sprite
|
||||
fuji.origin.setTo(1, 1);
|
||||
game.add.tween(fuji).to({
|
||||
rotation: 360
|
||||
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
|
||||
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,41 +1,44 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create);
|
||||
|
||||
function preload() {
|
||||
// Using Phasers asset loader we load up a PNG from the assets folder
|
||||
game.load.image('fuji', 'assets/pics/atari_fujilogo.png');
|
||||
}
|
||||
|
||||
var fuji;
|
||||
var tweenUp;
|
||||
var tweenDown;
|
||||
|
||||
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, game.stage.centerY, 'fuji');
|
||||
|
||||
// The sprite is 320 x 200 pixels in size
|
||||
// Here we set the origin to the center of the sprite again, so we can rotate and scale it at the same time
|
||||
fuji.transform.origin.setTo(0.5, 0.5);
|
||||
game.add.tween(fuji).to({
|
||||
rotation: 360
|
||||
}, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
|
||||
game.add.tween(fuji).to({ rotation: 360 }, 2000, Phaser.Easing.Linear.None, true, 0, true);
|
||||
|
||||
tweenUp = game.add.tween(fuji.transform.scale);
|
||||
tweenUp.onComplete.add(scaleDown, this);
|
||||
|
||||
tweenDown = game.add.tween(fuji.transform.scale);
|
||||
tweenDown.onComplete.add(scaleUp, this);
|
||||
|
||||
scaleUp();
|
||||
}
|
||||
|
||||
function scaleUp() {
|
||||
tweenUp.to({
|
||||
x: 2,
|
||||
y: 2
|
||||
}, 1000, Phaser.Easing.Elastic.Out);
|
||||
tweenUp.to({ x: 2, y: 2 }, 1000, Phaser.Easing.Elastic.Out);
|
||||
tweenUp.start();
|
||||
}
|
||||
|
||||
function scaleDown() {
|
||||
tweenDown.to({
|
||||
x: 0.5,
|
||||
y: 0.5
|
||||
}, 1000, Phaser.Easing.Elastic.Out);
|
||||
tweenDown.to({ x: 0.5, y: 0.5 }, 1000, Phaser.Easing.Elastic.Out);
|
||||
tweenDown.start();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
// Apply a 4px blur to the entire game (this value can be tweened, modified in-game, etc)
|
||||
game.stage.css3.blur = 4;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
// Apply a 150% brightness filter to the entire game (this value can be tweened, modified in-game, etc)
|
||||
game.stage.css3.brightness = 150;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
// Apply a 250% contrast filter to the entire game (this value can be tweened, modified in-game, etc)
|
||||
game.stage.css3.contrast = 250;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
// Apply a 100% contrast filter to the entire game (this value can be tweened, modified in-game, etc)
|
||||
game.stage.css3.grayscale = 100;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
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;
|
||||
|
||||
function create() {
|
||||
game.world.setSize(800, 800);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
game.add.sprite(30, 20, 'coke');
|
||||
game.add.sprite(600, 20, 'mushroom');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,30 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
game.world.setSize(1920, 1200);
|
||||
|
||||
game.add.sprite(0, 0, 'backdrop');
|
||||
|
||||
// Apply a 100% sepia filter to the entire game (this value can be tweened, modified in-game, etc)
|
||||
game.stage.css3.sepia = 100;
|
||||
}
|
||||
|
||||
function update() {
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -2,29 +2,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// CSV Tilemap Test
|
||||
// First we load our map data (a csv file)
|
||||
game.load.text('csvtest', 'assets/maps/catastrophi_level2.csv');
|
||||
|
||||
// Then we load the actual tile sheet image
|
||||
game.load.image('csvtiles', 'assets/tiles/catastrophi_tiles_16.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// This creates the tilemap using the csv and tile sheet we loaded.
|
||||
// We tell it use to CSV format parser. The 16x16 are the tile sizes.
|
||||
// The 4th parameter (true) tells the game world to resize itself based on the map dimensions or not.
|
||||
game.add.tilemap('csvtiles', 'csvtest', Phaser.Tilemap.FORMAT_CSV, true, 16, 16);
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Simple camera controls
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,20 +2,25 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
game.load.text('platform', 'assets/maps/mapdraw.json');
|
||||
game.load.image('tiles', 'assets/tiles/platformer_tiles.png');
|
||||
game.load.image('carrot', 'assets/sprites/carrot.png');
|
||||
}
|
||||
|
||||
var map;
|
||||
var emitter;
|
||||
var marker;
|
||||
|
||||
function create() {
|
||||
map = game.add.tilemap('tiles', 'platform', Phaser.Tilemap.FORMAT_TILED_JSON);
|
||||
map.setCollisionRange(21, 53);
|
||||
map.setCollisionRange(105, 109);
|
||||
|
||||
game.camera.texture.opaque = true;
|
||||
game.camera.texture.backgroundColor = 'rgb(47,154,204)';
|
||||
|
||||
marker = game.add.sprite(0, 0);
|
||||
marker.texture.width = 16;
|
||||
marker.texture.height = 16;
|
||||
@@ -27,13 +32,15 @@
|
||||
//emitter.gravity = 150;
|
||||
//emitter.bounce = 0.8;
|
||||
//emitter.start(false, 20, 0.05);
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Collide everything with the map
|
||||
//map.collide();
|
||||
marker.x = game.math.snapToFloor(game.input.worldX, 16);
|
||||
marker.y = game.math.snapToFloor(game.input.worldY, 16);
|
||||
if(game.input.mousePointer.isDown) {
|
||||
|
||||
if (game.input.mousePointer.isDown) {
|
||||
map.putTile(marker.x, marker.y, 32);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,31 +2,36 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// Tiled Tilemap Test
|
||||
// First we load our map data (a json file exported from the map editor Tiled)
|
||||
// This data file has several layers within it. Phaser will render them all.
|
||||
game.load.text('jsontest', 'assets/maps/multi-layer-test.json');
|
||||
|
||||
// Then we load the actual tile sheet image
|
||||
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
|
||||
}
|
||||
|
||||
var map;
|
||||
|
||||
function create() {
|
||||
// This creates the tilemap using the json data and tile sheet we loaded.
|
||||
// We tell it to use the Tiled JSON format parser.
|
||||
map = game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
|
||||
//map.currentLayer.
|
||||
}
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Simple camera controls
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,33 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var game = new Phaser.Game(this, 'game', 800, 600, preload, create, update);
|
||||
|
||||
function preload() {
|
||||
// Tiled Tilemap Test
|
||||
// First we load our map data (a json file exported from the map editor Tiled)
|
||||
game.load.text('jsontest', 'assets/maps/test.json');
|
||||
|
||||
//myGame.loader.addTextFile('jsontest', 'assets/maps/multi-layer-test.json');
|
||||
// Then we load the actual tile sheet image
|
||||
game.load.image('jsontiles', 'assets/tiles/platformer_tiles.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
// This creates the tilemap using the json data and tile sheet we loaded.
|
||||
// We tell it to use the Tiled JSON format parser.
|
||||
game.add.tilemap('jsontiles', 'jsontest', Phaser.Tilemap.FORMAT_TILED_JSON);
|
||||
}
|
||||
|
||||
function update() {
|
||||
// Simple camera controls
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
game.camera.x -= 4;
|
||||
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
} else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
game.camera.x += 4;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user