forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular velocity.php
More file actions
61 lines (43 loc) · 1.48 KB
/
Copy pathangular velocity.php
File metadata and controls
61 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$title = "Angular Velocity";
require('../head.php');
?>
<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('arrow', 'assets/sprites/arrow.png');
}
var sprite;
function create() {
game.stage.backgroundColor = '#0072bc';
sprite = game.add.sprite(400, 300, 'arrow');
sprite.anchor.setTo(0.5, 0.5);
}
function update() {
sprite.body.velocity.x = 0;
sprite.body.velocity.y = 0;
sprite.body.angularVelocity = 0;
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
sprite.body.angularVelocity = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
sprite.body.angularVelocity = 200;
}
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
game.physics.velocityFromAngle(sprite.angle, 300, sprite.body.velocity);
}
}
function render() {
game.debug.renderSpriteInfo(sprite, 32, 32);
game.debug.renderText('angularVelocity: ' + sprite.body.angularVelocity, 32, 200);
game.debug.renderText('angularAcceleration: ' + sprite.body.angularAcceleration, 32, 232);
game.debug.renderText('angularDrag: ' + sprite.body.angularDrag, 32, 264);
game.debug.renderText('deltaZ: ' + sprite.body.deltaZ(), 32, 296);
}
</script>
<?php
require('../foot.php');
?>