Loads of new examples, some more bug fixes, all of them work beautifully

This commit is contained in:
Webeled
2013-10-14 19:32:07 +01:00
parent faf432bdb0
commit 969fa46484
24 changed files with 400 additions and 38 deletions
+32
View File
@@ -0,0 +1,32 @@
<?php
$title = "Circle";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,render:render});
var circle;
var floor;
function create() {
circle = new Phaser.Circle(game.world.centerX, 100,64);
}
function render () {
game.debug.renderCircle(circle,'#cfffff');
game.debug.renderText('Diameter : '+circle.diameter,50,200);
game.debug.renderText('Circumference : '+circle.circumference(),50,230);
}
</script>
<?php
require('../foot.php');
?>
+32
View File
@@ -0,0 +1,32 @@
<?php
$title = "Rectangle";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {create: create});
function create() {
var graphics = game.add.graphics(50,50);
// set a fill and line style
graphics.beginFill(0xFF0000);
graphics.lineStyle(10, 0xFF0000, 1);
// draw a shape
graphics.moveTo(50,50);
graphics.lineTo(250, 50);
graphics.endFill();
}
</script>
<?php
require('../foot.php');
?>
+70
View File
@@ -0,0 +1,70 @@
<?php
$title = "Rotate point";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});
var p1;
var p2;
var p3;
var p4;
var d2 = 0;
var d3 = 0;
var d4 = 0;
function create() {
p1 = new Phaser.Point(game.world.centerX, game.world.centerY);
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
p4 = new Phaser.Point(p3.x - 50, p3.y - 50);
}
function update() {
p2.rotate(p1.x, p1.y, game.math.wrapAngle(d2), true, 150);
p3.rotate(p2.x, p2.y, game.math.wrapAngle(d3), true, 50);
p4.rotate(p3.x, p3.y, game.math.wrapAngle(d4), true, 100);
d2 += 1;
d3 += 4;
d4 += 6;
}
function render() {
game.context.strokeStyle = 'rgb(0,255,255)';
game.context.beginPath();
game.context.moveTo(p1.x, p1.y);
game.context.lineTo(p2.x, p2.y);
game.context.lineTo(p3.x, p3.y);
game.context.lineTo(p4.x, p4.y);
game.context.stroke();
game.context.closePath();
game.context.fillStyle = 'rgb(255,255,0)';
game.context.fillRect(p1.x, p1.y, 4, 4);
game.context.fillStyle = 'rgb(255,0,0)';
game.context.fillRect(p2.x, p2.y, 4, 4);
game.context.fillStyle = 'rgb(0,255,0)';
game.context.fillRect(p3.x, p3.y, 4, 4);
game.context.fillStyle = 'rgb(255,0,255)';
game.context.fillRect(p4.x, p4.y, 4, 4);
}
</script>
<?php
require('../foot.php');
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
$title = "Rectangle";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,render:render});
var floor;
function create() {
// A simple floor
floor = new Phaser.Rectangle(0, 550,800,50);
}
function render () {
game.debug.renderRectangle(floor,'#0fffff');
}
</script>
<?php
require('../foot.php');
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
$title = "Rotate point";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});
var p1;
var p2;
var d=0;
function create() {
p1 = new Phaser.Point(200, 300);
p2 = new Phaser.Point(300, 300);
}
function update() {
p1.rotate(p2.x, p2.y, game.math.wrapAngle(d), true);
d++;
}
function render() {
game.context.fillStyle = 'rgb(255,255,0)';
game.context.fillRect(p1.x, p1.y, 4, 4);
game.context.fillStyle = 'rgb(255,0,0)';
game.context.fillRect(p2.x, p2.y, 4, 4);
}
</script>
<?php
require('../foot.php');
?>