mirror of
https://github.com/wassname/phaser.git
synced 2026-07-22 12:50:19 +08:00
Final commit before rebuilding the Tilemap system.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
game.stage.backgroundColor = '#000000';
|
||||
|
||||
bg = game.add.tileSprite(0, 0, 800, 600, 'background');
|
||||
bg.fixedToCamera = true;
|
||||
|
||||
map = game.add.tilemap(0, 0, 'level1');
|
||||
map.setCollisionRange(1, 12, true, true, true, true);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
$title = "Test Title";
|
||||
$title = "Tilemap Collision";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
var map;
|
||||
var p;
|
||||
var cursors;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -31,42 +32,51 @@
|
||||
|
||||
p = game.add.sprite(32, 32, 'player');
|
||||
|
||||
p.body.gravity.y = 10;
|
||||
p.body.bounce.y = 0.4;
|
||||
p.body.collideWorldBounds = true;
|
||||
|
||||
game.world.setBounds(0, 0, map.width, 600);
|
||||
|
||||
game.camera.follow(p);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// map.collide(p);
|
||||
map.collide(p);
|
||||
|
||||
p.body.velocity.x = 0;
|
||||
// p.body.acceleration.y = 500;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
p.body.velocity.x = -150;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
p.body.velocity.x = 150;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
if (p.body.touching.down)
|
||||
{
|
||||
p.body.velocity.y = -200;
|
||||
p.body.velocity.y = -400;
|
||||
}
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
// game.camera.y += 4;
|
||||
}
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
p.body.velocity.x = -150;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
p.body.velocity.x = 150;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(p);
|
||||
game.debug.renderCameraInfo(game.camera, 32, 32);
|
||||
// game.debug.renderSpriteCorners(p);
|
||||
game.debug.renderSpriteCollision(p, 32, 320);
|
||||
|
||||
}
|
||||
|
||||
@@ -71,10 +71,6 @@ window.onload = function () {
|
||||
function render() {
|
||||
|
||||
game.debug.renderCameraInfo(game.camera, 32, 32);
|
||||
// game.debug.renderSpriteInfo(d, 32, 200);
|
||||
// game.debug.renderWorldTransformInfo(d, 32, 200);
|
||||
// game.debug.renderLocalTransformInfo(d, 32, 400);
|
||||
// game.debug.renderSpriteCorners(d, false, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user