Fixed gruntfile and included new labs demo.

This commit is contained in:
photonstorm 2014-03-06 10:01:46 +00:00
parent 6815c5909a
commit 512b542e50
3 changed files with 129 additions and 17 deletions

View file

@ -180,26 +180,26 @@ module.exports = function (grunt) {
'src/utils/Debug.js',
'src/utils/Color.js',
'/src/physics/Physics.js',
'src/physics/Physics.js',
'/src/physics/arcade/World.js',
'/src/physics/arcade/Body.js',
'/src/physics/arcade/QuadTree.js',
'src/physics/arcade/World.js',
'src/physics/arcade/Body.js',
'src/physics/arcade/QuadTree.js',
'/src/physics/ninja/World.js',
'/src/physics/ninja/Body.js',
'/src/physics/ninja/AABB.js',
'/src/physics/ninja/Tile.js',
'/src/physics/ninja/Circle.js',
'src/physics/ninja/World.js',
'src/physics/ninja/Body.js',
'src/physics/ninja/AABB.js',
'src/physics/ninja/Tile.js',
'src/physics/ninja/Circle.js',
'/src/physics/p2/World.js',
'/src/physics/p2/PointProxy.js',
'/src/physics/p2/InversePointProxy.js',
'/src/physics/p2/Body.js',
'/src/physics/p2/Spring.js',
'/src/physics/p2/Material.js',
'/src/physics/p2/ContactMaterial.js',
'/src/physics/p2/CollisionGroup.js',
'src/physics/p2/World.js',
'src/physics/p2/PointProxy.js',
'src/physics/p2/InversePointProxy.js',
'src/physics/p2/Body.js',
'src/physics/p2/Spring.js',
'src/physics/p2/Material.js',
'src/physics/p2/ContactMaterial.js',
'src/physics/p2/CollisionGroup.js',
'src/particles/Particles.js',
'src/particles/arcade/ArcadeParticles.js',

View file

@ -1,5 +1,9 @@
{
"animation": [
{
"file": "animation+events.js",
"title": "animation events"
},
{
"file": "change+texture+on+click.js",
"title": "change texture on click"
@ -788,10 +792,22 @@
"file": "kern+of+duty.js",
"title": "kern of duty"
},
{
"file": "littera.js",
"title": "littera"
},
{
"file": "remove+text.js",
"title": "remove text"
},
{
"file": "retro+font+1.js",
"title": "retro font 1"
},
{
"file": "retro+font+2.js",
"title": "retro font 2"
},
{
"file": "text+stroke.js",
"title": "text stroke"
@ -912,6 +928,10 @@
"file": "fading+in+a+sprite.js",
"title": "fading in a sprite"
},
{
"file": "generate+data.js",
"title": "generate data"
},
{
"file": "pause+tween.js",
"title": "pause tween"

View file

@ -0,0 +1,92 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.spritesheet('ninja-tiles', 'assets/physics/ninja-tiles32.png', 32, 32, 34);
game.load.json('level', 'assets/physics/ninja-test-level.json');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.image('sky', 'assets/skies/sky2.png');
}
var sprite1;
var tiles;
var cursors;
function create() {
var sky = game.add.image(0, 0, 'sky');
sky.fixedToCamera = true;
// Activate the Ninja physics system
game.physics.startSystem(Phaser.Physics.NINJA);
sprite1 = game.add.sprite(100, 0, 'ball');
// Enable the physics body for the Ninja physics system
game.physics.ninja.enableCircle(sprite1, sprite1.width / 2);
// A little more bounce
sprite1.body.bounce = 0.5;
// We'll just create the tiles from the JSON data
var layer = game.cache.getJSON('level').layers[0];
var i = 0;
var data = layer.data;
var width = layer.width;
var height = layer.height;
// Resize the world to match
game.world.setBounds(0, 0, width * 32, height * 32);
tiles = game.add.group();
var tile;
for (var y = 0; y < height; y++)
{
for (var x = 0; x < width; x++)
{
if (data[i] > 0)
{
tile = tiles.create(x * 32, y * 32, 'ninja-tiles', data[i] - 1);
game.physics.ninja.enableTile(tile, tile.frame);
}
i++;
}
}
cursors = game.input.keyboard.createCursorKeys();
game.camera.follow(sprite1);
}
function update() {
game.physics.ninja.collide(sprite1, tiles);
if (cursors.left.isDown)
{
sprite1.body.moveLeft(20);
}
else if (cursors.right.isDown)
{
sprite1.body.moveRight(20);
}
if (cursors.up.isDown)
{
sprite1.body.moveUp(20);
}
else if (cursors.down.isDown)
{
sprite1.body.moveUp(20);
}
}
function render() {
}