Tiling Sprite added

This commit is contained in:
Richard Davey
2013-09-03 03:19:42 +01:00
parent c18de53bab
commit 66e86e7d82
10 changed files with 524 additions and 15 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

+1
View File
@@ -63,6 +63,7 @@
<script src="../src/system/Canvas.js"></script>
<script src="../src/gameobjects/GameObjectFactory.js"></script>
<script src="../src/gameobjects/Sprite.js"></script>
<script src="../src/gameobjects/TileSprite.js"></script>
<script src="../src/system/Canvas.js"></script>
<script src="../src/system/Device.js"></script>
+76
View File
@@ -0,0 +1,76 @@
<!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.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/p2.jpeg');
}
var s;
var count = 0;
function create() {
game.world._stage.backgroundColorString = '#182d3b';
s = game.add.tileSprite(0, 0, 512, 512, 'disk');
// s.rotation = 0.1;
}
function update() {
count += 0.005
// s.rotation += 0.01;
s.tileScale.x = 2 + Math.sin(count);
s.tileScale.y = 2 + Math.cos(count);
s.tilePosition.x += 1;
s.tilePosition.y += 1;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.x -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.x += 4;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.y -= 4;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.y += 4;
}
}
function render() {
// game.debug.renderSpriteCorners(s, true, true);
}
})();
</script>
</body>
</html>
+54
View File
@@ -0,0 +1,54 @@
<!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 });
var s;
function preload() {
game.load.image('disk', 'assets/misc/starfield.jpg');
}
function create() {
s = game.add.tileSprite(0, 0, 800, 600, 'disk');
}
function update() {
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
s.tilePosition.x += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
s.tilePosition.x -= 8;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
s.tilePosition.y += 8;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
s.tilePosition.y -= 8;
}
}
})();
</script>
</body>
</html>