mirror of
https://github.com/wassname/phaser.git
synced 2026-07-23 13:00:41 +08:00
Preparing new tests
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.world.setSize(1920, 1920);
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var car;
|
||||
var melons;
|
||||
function create() {
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
melons = myGame.add.group();
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
|
||||
tempSprite.scrollFactor.setTo(1.2, 1.2);
|
||||
melons.add(tempSprite);
|
||||
}
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
myGame.camera.follow(car);
|
||||
}
|
||||
function update() {
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
|
||||
car.angularVelocity = -200;
|
||||
} else if(myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
if(myGame.input.keyboard.isDown(Phaser.Keyboard.UP)) {
|
||||
var motion = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -1,66 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.world.setSize(1920, 1920);
|
||||
|
||||
myGame.loader.addImageFile('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
myGame.loader.addImageFile('car', 'assets/sprites/car90.png');
|
||||
myGame.loader.addImageFile('melon', 'assets/sprites/melon.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var car: Phaser.Sprite;
|
||||
var melons: Phaser.Group;
|
||||
|
||||
function create() {
|
||||
|
||||
myGame.add.sprite(0, 0, 'grid');
|
||||
|
||||
melons = myGame.add.group();
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var tempSprite = myGame.add.sprite(Math.random() * myGame.world.width, Math.random() * myGame.world.height, 'melon');
|
||||
tempSprite.scrollFactor.setTo(1.2, 1.2);
|
||||
melons.add(tempSprite);
|
||||
}
|
||||
|
||||
car = myGame.add.sprite(400, 300, 'car');
|
||||
|
||||
myGame.camera.follow(car);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
car.velocity.x = 0;
|
||||
car.velocity.y = 0;
|
||||
car.angularVelocity = 0;
|
||||
car.angularAcceleration = 0;
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
car.angularVelocity = -200;
|
||||
}
|
||||
else if (myGame.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
car.angularVelocity = 200;
|
||||
}
|
||||
|
||||
if (myGame.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
var motion:Phaser.Point = myGame.motion.velocityFromAngle(car.angle, 300);
|
||||
|
||||
car.velocity.copyFrom(motion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,32 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
(function () {
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
function init() {
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
myGame.loader.load();
|
||||
}
|
||||
var items;
|
||||
var card;
|
||||
function create() {
|
||||
items = myGame.add.group();
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
items.add(myGame.add.sprite(64, 100, 'atari1'));
|
||||
card = items.add(myGame.add.sprite(240, 80, 'card'));
|
||||
items.add(myGame.add.sprite(280, 100, 'atari2'));
|
||||
myGame.input.onTap.addOnce(removeCard, this);
|
||||
}
|
||||
function removeCard() {
|
||||
// Now let's kill the card sprite
|
||||
card.kill();
|
||||
myGame.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();
|
||||
}
|
||||
function update() {
|
||||
}
|
||||
})();
|
||||
@@ -1,56 +0,0 @@
|
||||
/// <reference path="../../Phaser/Game.ts" />
|
||||
|
||||
(function () {
|
||||
|
||||
var myGame = new Phaser.Game(this, 'game', 800, 600, init, create, update);
|
||||
|
||||
function init() {
|
||||
|
||||
myGame.loader.addImageFile('atari1', 'assets/sprites/atari130xe.png');
|
||||
myGame.loader.addImageFile('atari2', 'assets/sprites/atari800xl.png');
|
||||
myGame.loader.addImageFile('card', 'assets/sprites/mana_card.png');
|
||||
|
||||
myGame.loader.load();
|
||||
|
||||
}
|
||||
|
||||
var items: Phaser.Group;
|
||||
var card: Phaser.Sprite;
|
||||
|
||||
function create() {
|
||||
|
||||
items = myGame.add.group();
|
||||
|
||||
// Items are rendered in the depth order in which they are added to the Group
|
||||
|
||||
items.add(myGame.add.sprite(64, 100, 'atari1'));
|
||||
card = <Phaser.Sprite> items.add(myGame.add.sprite(240, 80, 'card'));
|
||||
items.add(myGame.add.sprite(280, 100, 'atari2'));
|
||||
|
||||
myGame.input.onTap.addOnce(removeCard, this);
|
||||
|
||||
}
|
||||
|
||||
function removeCard() {
|
||||
|
||||
// Now let's kill the card sprite
|
||||
card.kill();
|
||||
|
||||
myGame.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();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user