Flixel level separation merged with the new Physics shapes.

This commit is contained in:
Richard Davey
2013-05-31 04:20:49 +01:00
parent 3e53c0671d
commit 39e7b84cd9
18 changed files with 1782 additions and 208 deletions
+5 -5
View File
@@ -14,15 +14,15 @@
//atari = game.add.sprite(350, 500, 'atari');
atari = game.add.sprite(0, 310, 'atari');
card = game.add.sprite(400, 300, 'card');
card.physics.immovable = true;
//card.physics.immovable = true;
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.physics.shape.setSize(150, 50);
//atari.physics.shape.offset.setTo(50, 25);
atari.physics.shape.setSize(150, 50);
atari.physics.shape.offset.setTo(50, 25);
//atari.physics.gravity.setTo(0, 2);
atari.physics.bounce.setTo(0.7, 0.7);
atari.physics.bounce.setTo(1, 1);
//atari.physics.drag.setTo(10, 10);
//card.physics.bounce.setTo(0.7, 0.7);
card.physics.bounce.setTo(0.7, 0.7);
//card.physics.velocity.x = -50;
}
function update() {
+5 -5
View File
@@ -23,19 +23,19 @@
atari = game.add.sprite(0, 310, 'atari');
card = game.add.sprite(400, 300, 'card');
card.physics.immovable = true;
//card.physics.immovable = true;
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
//atari.physics.shape.setSize(150, 50);
//atari.physics.shape.offset.setTo(50, 25);
atari.physics.shape.setSize(150, 50);
atari.physics.shape.offset.setTo(50, 25);
//atari.physics.gravity.setTo(0, 2);
atari.physics.bounce.setTo(0.7, 0.7);
atari.physics.bounce.setTo(1, 1);
//atari.physics.drag.setTo(10, 10);
//card.physics.bounce.setTo(0.7, 0.7);
card.physics.bounce.setTo(0.7, 0.7);
//card.physics.velocity.x = -50;
}
+12 -1
View File
@@ -4,12 +4,15 @@
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari', 'assets/sprites/mushroom2.png');
game.loader.addImageFile('card', 'assets/sprites/mana_card.png');
game.loader.load();
}
var atari;
var card;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.5;
card = game.add.sprite(400, 300, 'card');
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
atari.physics.setCircle(50);
//atari.physics.shape.setSize(150, 50);
@@ -17,6 +20,7 @@
//atari.physics.gravity.setTo(0, 2);
atari.physics.bounce.setTo(0.7, 0.7);
atari.physics.drag.setTo(10, 10);
card.physics.bounce.setTo(0.7, 0.7);
}
function update() {
atari.physics.acceleration.x = 0;
@@ -34,5 +38,12 @@
}
function render() {
atari.physics.renderDebugInfo(16, 16);
game.stage.context.save();
game.stage.context.beginPath();
game.stage.context.strokeStyle = 'rgba(255,0,255,0.5)';
game.stage.context.arc(200, 200, 50, 0, Math.PI * 2);
game.stage.context.stroke();
game.stage.context.closePath();
game.stage.context.restore();
}
})();
+15 -1
View File
@@ -8,16 +8,19 @@
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari', 'assets/sprites/mushroom2.png');
game.loader.addImageFile('card', 'assets/sprites/mana_card.png');
game.loader.load();
}
var atari: Phaser.Sprite;
var card: Phaser.Sprite;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.5;
card = game.add.sprite(400, 300, 'card');
//atari.texture.alpha = 0.5;
//atari.scale.setTo(1.5, 1.5);
atari.physics.setCircle(50);
@@ -29,6 +32,8 @@
atari.physics.bounce.setTo(0.7, 0.7);
atari.physics.drag.setTo(10, 10);
card.physics.bounce.setTo(0.7, 0.7);
}
function update() {
@@ -60,6 +65,15 @@
atari.physics.renderDebugInfo(16, 16);
game.stage.context.save();
game.stage.context.beginPath();
game.stage.context.strokeStyle = 'rgba(255,0,255,0.5)';
game.stage.context.arc(200, 200, 50, 0, Math.PI * 2);
game.stage.context.stroke();
game.stage.context.closePath();
game.stage.context.restore();
}
})();
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Polygon.ts" />
/// <reference path="../../Phaser/utils/SpriteUtils.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png');
game.loader.load();
}
var atari;
var p;
var atari2;
var p2;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.2;
atari2 = game.add.sprite(500, 300, 'atari');
atari2.texture.alpha = 0.2;
p = new Phaser.Polygon(game, Phaser.SpriteUtils.getAsPoints(atari));
p2 = new Phaser.Polygon(game, Phaser.SpriteUtils.getAsPoints(atari2));
}
function update() {
atari.physics.acceleration.x = 0;
atari.physics.acceleration.y = 0;
if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
atari.physics.acceleration.x = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
atari.physics.acceleration.x = 150;
}
if(game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
atari.physics.acceleration.y = -150;
} else if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
atari.physics.acceleration.y = 150;
}
}
function render() {
atari.physics.renderDebugInfo(16, 16);
p.render();
p2.render();
}
})();
+70
View File
@@ -0,0 +1,70 @@
/// <reference path="../../Phaser/Game.ts" />
/// <reference path="../../Phaser/core/Polygon.ts" />
/// <reference path="../../Phaser/utils/SpriteUtils.ts" />
(function () {
var game = new Phaser.Game(this, 'game', 800, 600, init, create, update, render);
function init() {
// Using Phasers asset loader we load up a PNG from the assets folder
game.loader.addImageFile('atari', 'assets/sprites/atari800xl.png');
game.loader.load();
}
var atari: Phaser.Sprite;
var p: Phaser.Polygon;
var atari2: Phaser.Sprite;
var p2: Phaser.Polygon;
function create() {
atari = game.add.sprite(200, 300, 'atari');
atari.texture.alpha = 0.2;
atari2 = game.add.sprite(500, 300, 'atari');
atari2.texture.alpha = 0.2;
p = new Phaser.Polygon(game, Phaser.SpriteUtils.getAsPoints(atari));
p2 = new Phaser.Polygon(game, Phaser.SpriteUtils.getAsPoints(atari2));
}
function update() {
atari.physics.acceleration.x = 0;
atari.physics.acceleration.y = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
atari.physics.acceleration.x = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
atari.physics.acceleration.x = 150;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
atari.physics.acceleration.y = -150;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
atari.physics.acceleration.y = 150;
}
}
function render() {
atari.physics.renderDebugInfo(16, 16);
p.render();
p2.render();
}
})();