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:
Richard Davey
2013-08-09 05:08:54 +01:00
parent 9bf7d070f5
commit 2d49a31ecd
182 changed files with 8444 additions and 991 deletions
+5
View File
@@ -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();
+40 -18
View File
@@ -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;
}
}
-3
View File
@@ -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;
+10 -4
View File
@@ -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 {
+6
View File
@@ -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);
}
+5
View File
@@ -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
View File
@@ -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.
+5
View File
@@ -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);