mirror of
https://github.com/wassname/phaser.git
synced 2026-07-19 11:26:26 +08:00
Tilemap Collision in and working :) Needs testing against Groups now.
This commit is contained in:
+4
-4
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging
|
||||
// All JS files in build order. Much easier for debugging
|
||||
// <xscript src="../src/pixi/extras/Spine.js"></script> <xscript src="../src/pixi/display/MovieClip.js"></script>
|
||||
?>
|
||||
<script src="../src/Intro.js"></script>
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
@@ -13,12 +13,12 @@
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
<script src="../src/pixi/display/MovieClip.js"></script>
|
||||
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="../src/pixi/extras/Strip.js"></script>
|
||||
<script src="../src/pixi/extras/Rope.js"></script>
|
||||
<script src="../src/pixi/extras/Spine.js"></script>
|
||||
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/MaskFilter.js"></script>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - a new beginning</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
// var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.image('player', 'assets/sprites/phaser-dude.png');
|
||||
|
||||
}
|
||||
|
||||
var map;
|
||||
var p;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#787878';
|
||||
|
||||
map = game.add.tilemap(0, 0, 'mario');
|
||||
|
||||
// floor
|
||||
map.setCollisionRange(80, 97, true, true, true, true);
|
||||
|
||||
// pipes
|
||||
// map.setCollisionRange(31, 32, true, true, true, true);
|
||||
// map.setCollisionRange(37, 38, true, true, true, true);
|
||||
// map.setCollisionRange(39, 40, true, true, true, true);
|
||||
// map.setCollisionRange(45, 46, true, true, true, true);
|
||||
// map.setCollisionRange(73, 74, true, true, true, true);
|
||||
|
||||
// one-ways
|
||||
map.setCollisionRange(15, 17, true, true, false, true);
|
||||
|
||||
p = game.add.sprite(0, 0, 'player');
|
||||
// p.body.velocity.y = 150;
|
||||
// p.body.gravity.y = 10;
|
||||
// p.body.bounce.y = 0.5;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
map.collide(p);
|
||||
|
||||
p.body.velocity.x = 0;
|
||||
p.body.acceleration.y = 250;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
p.body.velocity.x = -150;
|
||||
// game.camera.x -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
p.body.velocity.x = 150;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
if (p.body.touching.down)
|
||||
{
|
||||
p.body.velocity.y = -200;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(p);
|
||||
game.debug.renderSpriteCollision(p, 32, 320);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - Super Mario Combo</title>
|
||||
<script src="phaser-min.js"></script>
|
||||
<style type="text/css">
|
||||
body: {
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('nes', 'gfx/mario1.png', 'gfx/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('snes', 'gfx/smb_tiles.png', 'gfx/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#5c94fc';
|
||||
|
||||
game.add.tilemap(0, 0, 'nes');
|
||||
game.add.tilemap(0, 168, 'snes');
|
||||
|
||||
game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
game.input.onDown.add(goFull, this);
|
||||
|
||||
}
|
||||
|
||||
function goFull() {
|
||||
game.stage.scale.startFullScreen();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 809 B |
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
@@ -0,0 +1,65 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>phaser.js - Super Mario Combo</title>
|
||||
<script src="phaser-min.js"></script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: sans-serif;
|
||||
}
|
||||
|
||||
p {
|
||||
padding: 16px;
|
||||
margin: 0px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="game"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'game', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/phaser.png');
|
||||
game.load.tilemap('nes', 'assets/mario1.png', 'assets/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('snes', 'assets/smb_tiles.png', 'assets/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#5c94fc';
|
||||
|
||||
game.add.tilemap(0, 0, 'nes');
|
||||
game.add.tilemap(0, 168, 'snes');
|
||||
|
||||
var logo = game.add.sprite(688, 8, 'phaser');
|
||||
logo.scrollFactor.setTo(0, 0);
|
||||
|
||||
game.add.tween(game.camera).to( { x: 4320 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
game.input.onDown.add(goFull, this);
|
||||
|
||||
}
|
||||
|
||||
function goFull() {
|
||||
game.stage.scale.startFullScreen();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<p>Potential game idea here? :)</p>
|
||||
<p>Click game to full-screen (if supported)</p>
|
||||
<p>Created with <a href="https://github.com/photonstorm/phaser">Phaser 1.0</a> by <a href="https://twitter.com/photonstorm">@photonstorm</a></p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>phaser.js - Super Mario Combo</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
?>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('nes', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#5c94fc';
|
||||
|
||||
game.add.tilemap(0, 0, 'nes');
|
||||
game.add.tilemap(0, 168, 'snes');
|
||||
|
||||
game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
game.input.onDown.add(goFull, this);
|
||||
|
||||
}
|
||||
|
||||
function goFull() {
|
||||
game.stage.scale.startFullScreen();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user