Skip to content

Commit f5584bd

Browse files
committed
Lots of fixes and updates to ArcadePhysics and Group, plus more examples.
1 parent ebc4e5d commit f5584bd

20 files changed

Lines changed: 422 additions & 121 deletions

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ Version 1.0.7 (in progress in the dev branch)
9797
* Moved the Camera update checks to World.postUpdate, so all the sprites get the correct adjusted camera position.
9898
* Added Sprite.fixedToCamera boolean. A Sprite that is fixed to the camera doesn't move with the world, but has its x/y coordinates relative to the top-left of the camera.
9999
* Updated InputHandler to use Math.round rather than Math.floor when snapping an object during drag.
100-
100+
* If you didn't provide the useNumericIndex parameter then AnimationManager.add will set the value by looking at the datatype of the first element in the frames array.
101+
* Added Group.createMultiple - useful when you need to create a Group of identical sprites for pooling, such as bullets.
102+
* Group.create now sets the visible and alive properties of the Sprite to the same value as the 'exists' parameter.
103+
* Added Group.total. Same as Group.length, but more in line with the rest of the Group naming.
104+
* Added Sprite.outOfBoundsKill boolean flag. Will automatically kill a sprite that leaves the game World bounds (off by default).
105+
* ArcadePhysics.moveTowardsMouse changed to ArcadePhysics.moveTowardsPointer and now lets you specify which pointer to move towards (defaults to Input.activePointer).
106+
* ArcadePhysics.angleBetweenMouse changed to ArcadePhysics.angleBetweenPointer and now lets you specify which pointer to get the angle to (defaults to Input.activePointer).
107+
* ArcadePhysics.velocityFromAngle and ArcadePhysics.velocityFromRotation added with examples created.
101108

102109

103110
* TODO: look at Sprite.crop (http://www.html5gamedevs.com/topic/1617-error-in-spritecrop/)
@@ -106,6 +113,7 @@ Version 1.0.7 (in progress in the dev branch)
106113
* TODO: addMarker hh:mm:ss:ms
107114
* TODO: swap state (non-destructive shift)
108115
* TODO: rotation offset
116+
* TODO: check stage bgc on droid (http://www.html5gamedevs.com/topic/1629-stage-background-color-not-working-on-android-chrome/)
109117

110118

111119
Version 1.0.6 (September 24th 2013)
31.9 KB
Binary file not shown.
130 KB
Loading
3.5 KB
Loading
490 Bytes
Loading
231 KB
Binary file not shown.
224 KB
Binary file not shown.
1.05 KB
Loading

examples/input/multi touch.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,38 @@
55

66
<script type="text/javascript">
77

8-
9-
108
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create, render: render });
119

12-
1310
function create() {
1411

1512
game.stage.backgroundColor = '#454645';
1613

14+
// By default Phaser only starts 2 pointers (enough for 2 fingers at once)
15+
16+
// addPointer tells Phaser to add another pointer to Input, so here we are basically saying "allow up to 6 pointers + the mouse"
17+
18+
// Note: on iOS as soon as you use 6 fingers you'll active the minimise app gesture - and there's nothing we can do to stop that, sorry
19+
20+
game.input.addPointer();
21+
game.input.addPointer();
22+
game.input.addPointer();
23+
game.input.addPointer();
24+
1725
}
1826

1927
function render() {
2028

29+
// Just renders out the pointer data when you touch the canvas
2130
game.debug.renderPointer(game.input.mousePointer);
2231
game.debug.renderPointer(game.input.pointer1);
2332
game.debug.renderPointer(game.input.pointer2);
2433
game.debug.renderPointer(game.input.pointer3);
2534
game.debug.renderPointer(game.input.pointer4);
35+
game.debug.renderPointer(game.input.pointer5);
36+
game.debug.renderPointer(game.input.pointer6);
2637

2738
}
2839

29-
30-
3140
</script>
3241

3342
<?php
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
$title = "Angle between Sprite and Active Pointer";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
9+
10+
function preload() {
11+
game.load.image('arrow', 'assets/sprites/arrow.png');
12+
}
13+
14+
var sprite;
15+
16+
function create() {
17+
18+
game.stage.backgroundColor = '#0072bc';
19+
20+
sprite = game.add.sprite(400, 300, 'arrow');
21+
sprite.anchor.setTo(0.5, 0.5);
22+
23+
}
24+
25+
function update() {
26+
27+
// This will update the sprite.rotation so that it points to the currently active pointer
28+
// On a Desktop that is the mouse, on mobile the most recent finger press.
29+
sprite.rotation = game.physics.angleBetweenPointer(sprite);
30+
31+
}
32+
33+
function render() {
34+
35+
game.debug.renderSpriteInfo(sprite, 32, 32);
36+
37+
}
38+
39+
</script>
40+
41+
<?php
42+
require('../foot.php');
43+
?>

0 commit comments

Comments
 (0)