mirror of
https://github.com/wassname/phaser.git
synced 2026-07-25 13:20:14 +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,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);
|
||||
|
||||
Reference in New Issue
Block a user