mirror of
https://github.com/photonstorm/phaser
synced 2024-11-11 07:34:43 +00:00
1.0.3 release - fixed Text and Bitmap Fonts, Animation documentation and more examples
This commit is contained in:
parent
f4734b1143
commit
3c5ea01e09
29 changed files with 1253 additions and 392 deletions
BIN
Docs/Documentation Checklist.xlsx
Normal file
BIN
Docs/Documentation Checklist.xlsx
Normal file
Binary file not shown.
BIN
Docs/Screen Shots/phaser_fruit.png
Normal file
BIN
Docs/Screen Shots/phaser_fruit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 48 KiB |
BIN
Docs/Screen Shots/phaser_platformer.png
Normal file
BIN
Docs/Screen Shots/phaser_platformer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 83 KiB |
BIN
Docs/Screen Shots/phaser_quadtree.png
Normal file
BIN
Docs/Screen Shots/phaser_quadtree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
|
@ -34,11 +34,10 @@ public game: Phaser.Game;
|
|||
*/
|
||||
|
||||
/**
|
||||
* My property description. Like other pieces of your comment blocks,
|
||||
* this can span multiple lines.
|
||||
* Property description.
|
||||
*
|
||||
* @property propertyName
|
||||
* @public
|
||||
* @public @private
|
||||
* @type {Object}
|
||||
* @default "foo"
|
||||
*/
|
||||
|
|
18
README.md
18
README.md
|
@ -5,7 +5,7 @@ Phaser 1.0
|
|||
|
||||
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It supports Canvas and WebGL rendering.
|
||||
|
||||
Version: 1.0.2 - Released: September 15th 2013
|
||||
Version: 1.0.3 - Released: September 17th 2013
|
||||
|
||||
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
|
||||
|
||||
|
@ -20,10 +20,6 @@ Try out the [Phaser Test Suite](http://gametest.mobi/phaser/)
|
|||
Latest Update
|
||||
-------------
|
||||
|
||||
September 15th 2013
|
||||
|
||||
Version 1.0.1 and 1.0.2 have been tagged and released. See the Change Log for full details. As 1.0 is so fresh please expect small minor updates every few days, but we will be sure to tag them.
|
||||
|
||||
September 13th 2013
|
||||
|
||||
We're very pleased to have finally shipped the 1.0 release of Phaser. This version represents many months of hard work, feedback and refactoring based on the previous 0.5 through to 0.97 releases. You can see the full gory details in our change log.
|
||||
|
@ -41,7 +37,15 @@ Phaser is everything we ever wanted from an HTML5 game framework. It will power
|
|||
Change Log
|
||||
----------
|
||||
|
||||
Version 1.0.2
|
||||
Version 1.0.3 (September 17th 2013)
|
||||
|
||||
* FrameData.getFrameIndexes and getFrameIndexesByName refactored into a more versatile getFrames function.
|
||||
* Various fixes to looping parameters in the Sound system.
|
||||
* Documentation started across most classes. Keep track of progress in the Docs folder.
|
||||
* Optimised AnimationManager.add so it will only get the required frames rather than all of them and is now faster at parsing the frame data.
|
||||
* Fixed Phaser.Text and Phaser.BitmapText so they now render correctly and added several Text examples.
|
||||
|
||||
Version 1.0.2 (September 16th 2013)
|
||||
|
||||
* Added optional parameter to Animation.stop: resetFrame. If true the animation will be stopped and then the current frame reset to the first frame in the animation.
|
||||
* Fixed an issue causing 'explode' particle bursts to ignore the quantity parameter.
|
||||
|
@ -53,7 +57,7 @@ Version 1.0.2
|
|||
* Added in the start of a Breakout game
|
||||
* Added in the start of a Platformer game
|
||||
|
||||
Version 1.0.1
|
||||
Version 1.0.1 (September 15th 2013)
|
||||
|
||||
* Added checks into every Group function to ensure that the Group has children before running them.
|
||||
* Added optional flag to Group.create which allows you to set the default exists state of the Sprites.
|
||||
|
|
43
examples/animation/sprite sheet.php
Normal file
43
examples/animation/sprite sheet.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
$title = "Sprite Sheet";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
// 37x45 is the size of each frame
|
||||
|
||||
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
|
||||
// blank frames at the end, so we tell the loader how many to load
|
||||
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var mummy = game.add.sprite(300, 200, 'mummy');
|
||||
|
||||
// Here we add a new animation called 'walk'
|
||||
// Because we didn't give any other parameters it's going to make an animation from all available frames in the 'mummy' sprite sheet
|
||||
mummy.animations.add('walk');
|
||||
|
||||
// And this starts the animation playing by using its key ("walk")
|
||||
// 30 is the frame rate (30fps)
|
||||
// true means it will loop when it finishes
|
||||
mummy.animations.play('walk', 30, true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
38
examples/animation/texture atlas.php
Normal file
38
examples/animation/texture atlas.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
$title = "Animation from a Texture Atlas";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This sprite is using a texture atlas for all of its animation data
|
||||
var bot = game.add.sprite(200, 200, 'bot');
|
||||
|
||||
// Here we add a new animation called 'run'
|
||||
// We haven't specified any frames because it's using every frame in the texture atlas
|
||||
bot.animations.add('run');
|
||||
|
||||
// And this starts the animation playing by using its key ("run")
|
||||
// 15 is the frame rate (15fps)
|
||||
// true means it will loop when it finishes
|
||||
bot.animations.play('run', 15, true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
File diff suppressed because one or more lines are too long
|
@ -5,69 +5,69 @@
|
|||
</tileset>
|
||||
<layer name="Tile Layer 1" width="64" height="64">
|
||||
<data encoding="csv">
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,
|
||||
2,3,4,5,2,6,2,3,6,7,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,2,6,2,3,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
19,19,37,19,19,36,19,22,23,24,0,0,0,0,0,0,0,0,0,0,0,18,19,19,37,19,19,36,19,22,23,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
19,36,19,19,21,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,35,19,36,19,19,38,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,52,53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,19,19,
|
||||
6,2,3,6,7,0,0,0,0,0,0,13,14,0,0,0,0,0,0,13,14,0,0,0,0,1,34,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,19,19,19,19,
|
||||
36,19,22,23,24,0,0,0,0,0,1,30,31,9,0,0,0,0,1,30,31,9,0,0,0,59,55,57,60,0,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,19,19,19,19,19,
|
||||
19,19,39,40,41,0,0,0,0,0,25,19,19,26,0,0,0,0,25,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,64,65,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
20,54,55,57,60,0,0,0,0,0,59,57,53,60,0,0,0,0,59,57,53,60,0,0,0,0,0,0,0,0,0,0,0,0,59,57,56,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,
|
||||
24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
43,0,0,0,0,0,0,47,48,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,9,0,0,0,1,4,64,65,2,3,4,5,2,64,65,3,6,7,0,1,2,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,18,19,19,19,19,19,37,19,19,36,19,22,23,24,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,1,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,25,19,19,19,19,36,19,19,19,19,19,39,40,41,0,18,19,19,19,9,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,41,0,0,0,42,19,19,19,53,54,53,53,55,53,54,55,57,60,0,59,56,56,56,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
19,43,0,0,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,
|
||||
19,26,0,0,0,35,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,66,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
37,26,0,0,0,52,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,13,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,1,19,19,19,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,2,30,30,31,2,6,7,0,0,13,0,0,0,0,0,0,0,0,59,57,60,0,0,0,42,19,19,19,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,1,20,21,22,23,19,19,19,19,19,19,19,6,3,30,4,7,0,0,0,0,0,0,0,0,0,0,0,44,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,41,0,49,50,51,0,47,48,0,0,0,1,36,37,38,39,40,19,19,19,19,19,19,19,19,19,19,19,26,0,0,0,0,0,0,0,0,0,44,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,3,66,67,68,2,64,65,6,2,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,57,58,0,0,0,0,0,0,44,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,37,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,19,0,0,0,0,0,19,
|
||||
37,19,19,19,19,19,20,19,19,38,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,60,0,0,0,0,0,0,0,0,19,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,19,19,19,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,19,
|
||||
19,38,19,19,19,19,19,19,19,19,19,19,19,19,57,57,57,57,57,57,57,57,57,57,60,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,19,19,19,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,19,19,19,19,19,19,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,19,19,19,19,19,19,19,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,19,0,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,0,0,19,19,19,19,19,19,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,53,53,19,19,36,19,19,37,19,36,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,54,57,19,19,36,36,19,20,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,19,19,37,38,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,54,19,36,19,36,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,19,19,22,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,19,39,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,20,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,19,21,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,38,21,19,
|
||||
50,0,49,0,0,0,49,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,47,48,0,0,0,49,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,53,19,19,22,
|
||||
67,3,66,5,2,6,66,67,6,7,0,0,0,0,0,0,0,0,0,0,0,1,2,64,65,5,2,6,66,67,6,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,19,39,
|
||||
19,19,37,19,19,36,19,22,23,24,0,0,0,0,0,0,0,0,0,0,0,18,19,19,37,19,19,36,19,22,23,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,9,0,0,0,0,52,19,
|
||||
19,36,19,19,21,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,35,19,36,19,19,38,19,19,39,40,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,19,41,0,0,0,0,0,25,
|
||||
53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,52,53,54,53,53,55,53,54,55,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,57,53,60,0,0,0,0,0,18,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,6,5,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,54,55,57,58,0,0,0,0,0,0,8,9,0,0,0,0,0,0,0,0,0,42,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,6,19,41,0,0,0,0,0,0,0,50,8,19,
|
||||
6,2,3,6,7,0,0,0,0,0,0,13,14,0,0,0,0,0,0,13,14,0,0,0,0,1,34,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,57,53,60,0,0,0,0,0,0,1,67,19,19,
|
||||
36,19,22,23,24,0,0,0,0,0,1,30,31,9,0,0,0,0,1,30,31,9,0,0,0,59,55,57,60,0,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,19,19,
|
||||
19,19,39,40,41,0,0,0,0,0,25,19,19,26,0,0,0,0,25,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,64,65,9,0,0,0,0,0,46,7,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,19,19,19,
|
||||
20,54,55,57,60,0,0,0,0,0,59,57,53,60,0,0,0,0,59,57,53,60,0,0,0,0,0,0,0,0,0,0,0,0,59,57,56,60,0,0,0,0,1,5,19,7,0,0,0,0,0,0,0,0,0,0,0,0,52,57,54,53,19,19,
|
||||
24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,53,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,19,
|
||||
43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,58,0,0,0,0,14,14,14,0,0,0,0,0,0,0,0,0,0,35,
|
||||
43,0,0,0,0,0,0,47,48,0,0,0,0,0,47,48,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,31,31,31,9,17,0,0,0,0,0,0,0,0,18,
|
||||
19,9,0,0,0,1,4,64,65,2,3,4,5,2,64,65,3,6,7,0,1,2,2,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,19,36,57,60,0,0,0,0,0,0,0,0,25,
|
||||
19,26,0,0,0,18,19,19,19,19,19,37,19,19,36,19,22,23,24,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,1,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,60,0,0,0,0,0,0,0,0,0,0,42,
|
||||
19,43,0,0,0,25,19,19,19,19,36,19,19,19,19,19,39,40,41,0,18,19,19,19,9,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,42,
|
||||
19,41,0,0,0,42,19,19,19,53,54,53,53,55,53,54,55,57,60,0,59,56,56,56,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,6,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,
|
||||
19,43,0,0,0,18,19,19,24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,49,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,19,19,
|
||||
19,26,0,0,0,35,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,66,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,7,0,0,0,0,0,0,0,0,0,0,0,0,59,53,54,19,
|
||||
37,26,0,0,0,52,56,56,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13,13,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,9,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,19,
|
||||
19,26,0,0,0,0,0,0,0,0,0,0,0,0,1,2,3,4,2,30,30,31,2,6,7,0,0,13,0,0,0,0,0,0,0,0,59,57,60,0,0,0,0,0,0,0,0,0,0,0,0,59,19,19,19,0,0,0,0,0,0,0,0,19,
|
||||
19,43,0,0,0,0,0,0,0,0,0,0,0,1,20,21,22,23,19,19,19,19,19,19,19,6,3,30,4,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,41,0,49,50,51,0,47,48,0,0,0,1,36,37,38,39,40,19,19,19,19,19,19,19,19,19,19,19,26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,3,66,67,68,2,64,65,6,2,3,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,57,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,37,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,19,
|
||||
37,19,19,19,19,19,20,19,19,38,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
19,19,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,41,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
19,38,19,19,19,19,19,19,19,19,19,19,19,19,57,57,57,57,57,57,57,57,57,57,60,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,19,19,19,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,19,19,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,0,0,0,0,0,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,19,0,0,0,0,19,19,19,19,0,0,0,0,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,19,19,19,19,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
|
||||
19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,19,19,19,0,19,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,19,19,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,19,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,0,0,0,0,19,19,19,19,0,0,0,0,0,0,0,19,19,19,19,19,19,0,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
|
||||
19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19
|
||||
</data>
|
||||
</layer>
|
||||
|
|
68
examples/collision/bounding box.php
Normal file
68
examples/collision/bounding box.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
$title = "Modified bounding box";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<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('atari', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
sprite1 = game.add.sprite(50, 200, 'atari');
|
||||
sprite1.name = 'atari';
|
||||
sprite1.body.velocity.x = 100;
|
||||
|
||||
// This adjusts the collision body size.
|
||||
// 100x100 is the new width/height.
|
||||
// See the offset bounding box for another example.
|
||||
sprite1.body.setSize(100, 100, 0, 0);
|
||||
|
||||
sprite2 = game.add.sprite(700, 220, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
sprite2.body.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// object1, object2, collideCallback, processCallback, callbackContext
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
console.log(obj1.name + ' collided with ' + obj2.name);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderRectangle(sprite1.body);
|
||||
game.debug.renderRectangle(sprite2.body);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
66
examples/collision/larger bounding box.php
Normal file
66
examples/collision/larger bounding box.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
$title = "Larger bounding box";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<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('atari', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
sprite1 = game.add.sprite(50, 200, 'atari');
|
||||
sprite1.name = 'atari';
|
||||
sprite1.body.velocity.x = 100;
|
||||
|
||||
// In this example the new collision box is much larger than the original sprite
|
||||
sprite1.body.setSize(400, 50, -100, 20);
|
||||
|
||||
sprite2 = game.add.sprite(700, 220, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
sprite2.body.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// object1, object2, collideCallback, processCallback, callbackContext
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
console.log(obj1.name + ' collided with ' + obj2.name);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderRectangle(sprite1.body);
|
||||
game.debug.renderRectangle(sprite2.body);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
69
examples/collision/offset bounding box.php
Normal file
69
examples/collision/offset bounding box.php
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
$title = "Offset bounding box";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<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('atari', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
sprite1 = game.add.sprite(50, 200, 'atari');
|
||||
sprite1.name = 'atari';
|
||||
sprite1.body.velocity.x = 100;
|
||||
|
||||
// This adjusts the collision body size.
|
||||
// 100x50 is the new width/height.
|
||||
// 50, 25 is the X and Y offset of the newly sized box.
|
||||
// In this case the box is 50px in and 25px down.
|
||||
sprite1.body.setSize(100, 50, 50, 25);
|
||||
|
||||
sprite2 = game.add.sprite(700, 220, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
sprite2.body.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// object1, object2, collideCallback, processCallback, callbackContext
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
console.log(obj1.name + ' collided with ' + obj2.name);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderRectangle(sprite1.body);
|
||||
game.debug.renderRectangle(sprite2.body);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -41,6 +41,7 @@
|
|||
player = game.add.sprite(32, 32, 'dude');
|
||||
player.body.bounce.y = 0.2;
|
||||
player.body.collideWorldBounds = true;
|
||||
player.body.gravity.y = 10;
|
||||
|
||||
player.animations.add('left', [0, 1, 2, 3], 10, true);
|
||||
player.animations.add('turn', [4], 20, true);
|
||||
|
@ -55,7 +56,7 @@
|
|||
game.physics.collide(player, map);
|
||||
|
||||
player.body.velocity.x = 0;
|
||||
player.body.acceleration.y = 500;
|
||||
// player.body.acceleration.y = 500;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<script src="../src/core/Group.js"></script>
|
||||
<script src="../src/core/World.js"></script>
|
||||
<script src="../src/core/Game.js"></script>
|
||||
|
||||
<script src="../src/input/Input.js"></script>
|
||||
<script src="../src/input/Keyboard.js"></script>
|
||||
<script src="../src/input/Mouse.js"></script>
|
||||
|
@ -57,41 +58,51 @@
|
|||
<script src="../src/input/Pointer.js"></script>
|
||||
<script src="../src/input/Touch.js"></script>
|
||||
<script src="../src/input/InputHandler.js"></script>
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
|
||||
<script src="../src/gameobjects/Events.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/gameobjects/Text.js"></script>
|
||||
<script src="../src/gameobjects/BitmapText.js"></script>
|
||||
<script src="../src/gameobjects/Button.js"></script>
|
||||
<script src="../src/gameobjects/Graphics.js"></script>
|
||||
<script src="../src/gameobjects/RenderTexture.js"></script>
|
||||
<script src="../src/gameobjects/BitmapText.js"></script>
|
||||
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/system/StageScaleMode.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/math/QuadTree.js"></script>
|
||||
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Rectangle.js"></script>
|
||||
|
||||
<script src="../src/net/Net.js"></script>
|
||||
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
|
||||
<script src="../src/time/Time.js"></script>
|
||||
|
||||
<script src="../src/animation/AnimationManager.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/Parser.js"></script>
|
||||
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/loader/Parser.js"></script>
|
||||
|
||||
<script src="../src/sound/Sound.js"></script>
|
||||
<script src="../src/sound/SoundManager.js"></script>
|
||||
|
||||
<script src="../src/utils/Debug.js"></script>
|
||||
<script src="../src/utils/Color.js"></script>
|
||||
|
||||
|
|
29
examples/text/bitmap fonts.php
Normal file
29
examples/text/bitmap fonts.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
$title = "Bitmap Fonts ahoy";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.bitmapText(200, 100, 'Phaser & Pixi\nrocking!', { font: '64px Desyrel', align: 'center' });
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
28
examples/text/hello arial.php
Normal file
28
examples/text/hello arial.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
$title = "Hello Arial";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create });
|
||||
|
||||
function create() {
|
||||
|
||||
var text = "- phaser -\nwith a sprinkle of\npixi dust";
|
||||
var style = { font: "65px Arial", fill: "#ff0044", align: "center" };
|
||||
|
||||
var t = game.add.text(game.world.centerX, game.world.centerY, text, style);
|
||||
t.anchor.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
78
examples/text/kern of duty.php
Normal file
78
examples/text/kern of duty.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
$title = "Kern of Duty";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
var content = [
|
||||
" ",
|
||||
"photon storm presents",
|
||||
"a phaser production",
|
||||
" ",
|
||||
"Kern of Duty",
|
||||
" ",
|
||||
"directed by rich davey",
|
||||
"rendering by mat groves",
|
||||
" ",
|
||||
"03:45, November 4th, 2014",
|
||||
"somewhere in the north pacific",
|
||||
"mission control bravo ...",
|
||||
];
|
||||
|
||||
var t = 0;
|
||||
var s;
|
||||
var index = 0;
|
||||
var line = '';
|
||||
|
||||
function preload() {
|
||||
game.load.image('cod', 'assets/pics/cod.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(0, 0, 'cod');
|
||||
|
||||
var style = { font: "30pt Courier", fill: "#19cb65", stroke: "#119f4e", strokeThickness: 2 };
|
||||
|
||||
s = game.add.text(32, 380, '', style);
|
||||
t = game.time.now + 80;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.time.now > t && index < content.length)
|
||||
{
|
||||
// get the next character in the line
|
||||
if (line.length < content[index].length)
|
||||
{
|
||||
line = content[index].substr(0, line.length + 1);
|
||||
s.setText(line);
|
||||
t = game.time.now + 80;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = game.time.now + 2000;
|
||||
|
||||
if (index < content.length)
|
||||
{
|
||||
index++;
|
||||
line = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
34
examples/text/text stroke.php
Normal file
34
examples/text/text stroke.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
$title = "Text Stroke";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create, update: update });
|
||||
|
||||
var s;
|
||||
|
||||
function create() {
|
||||
|
||||
var text = "--- phaser ---\nwith a sprinkle of\npixi dust";
|
||||
var style = { font: "bold 40pt Arial", fill: "#ffffff", align: "center", stroke: "#258acc", strokeThickness: 8 };
|
||||
|
||||
s = game.add.text(game.world.centerX, game.world.centerY, text, style);
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
s.angle += 1;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
var Phaser = Phaser || {
|
||||
|
||||
VERSION: '1.0.2',
|
||||
VERSION: '1.0.3',
|
||||
GAMES: [],
|
||||
AUTO: 0,
|
||||
CANVAS: 1,
|
||||
|
|
|
@ -1,43 +1,126 @@
|
|||
/**
|
||||
* Animation
|
||||
*
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
* It is created by the AnimationManager and belongs to Game Objects such as Sprite.
|
||||
*
|
||||
* @package Phaser.Animation
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
*
|
||||
* @param parent {Sprite} Owner sprite of this animation.
|
||||
* @param frameData {FrameData} The FrameData object contains animation data.
|
||||
* @param name {string} Unique name of this animation.
|
||||
* @param frames {number[]/string[]} An array of numbers or strings indicating what frames to play in what order.
|
||||
* @param delay {number} Time between frames in ms.
|
||||
* @param looped {bool} Whether or not the animation is looped or just plays once.
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
Phaser.Animation = function (game, parent, frameData, name, frames, delay, looped) {
|
||||
|
||||
/**
|
||||
* An Animation instance contains a single animation and the controls to play it.
|
||||
* It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.
|
||||
*
|
||||
* @class Animation
|
||||
* @constructor
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {Phaser.Sprite} parent A reference to the owner of this Animation.
|
||||
* @param {String} name The unique name for this animation, used in playback commands.
|
||||
* @param {Phaser.Animation.FrameData} frameData The FrameData object that contains all frames used by this Animation.
|
||||
* @param {Mixed} frames An array of numbers or strings indicating which frames to play in which order.
|
||||
* @param {Number} delay The time between each frame of the animation, given in ms.
|
||||
* @param {Boolean} looped Should this animation loop or play through once.
|
||||
*/
|
||||
Phaser.Animation = function (game, parent, name, frameData, frames, delay, looped) {
|
||||
|
||||
/**
|
||||
* A reference to the currently running Game.
|
||||
* @property game
|
||||
* @public
|
||||
* @type {Phaser.Game}
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* A reference to the parent Sprite that owns this Animation.
|
||||
* @property _parent
|
||||
* @private
|
||||
* @type {Phaser.Sprite}
|
||||
*/
|
||||
this._parent = parent;
|
||||
|
||||
/**
|
||||
* The FrameData the Animation uses.
|
||||
* @property _frameData
|
||||
* @private
|
||||
* @type {Phaser.FrameData}
|
||||
*/
|
||||
this._frameData = frameData;
|
||||
|
||||
/**
|
||||
* The user defined name given to this Animation.
|
||||
* @property name
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* @property _frames
|
||||
* @private
|
||||
* @type {Object}
|
||||
*/
|
||||
this._frames = frames;
|
||||
this._frameData = frameData;
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* The delay in ms between each frame of the Animation.
|
||||
* @property delay
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.delay = 1000 / delay;
|
||||
|
||||
/**
|
||||
* The loop state of the Animation.
|
||||
* @property looped
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.looped = looped;
|
||||
|
||||
/**
|
||||
* The finished state of the Animation. Set to true once playback completes, false during playback.
|
||||
* @property isFinished
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
* default true
|
||||
*/
|
||||
this.isFinished = false;
|
||||
|
||||
/**
|
||||
* The playing state of the Animation. Set to false once playback completes, true during playback.
|
||||
* @property isPlaying
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
* default false
|
||||
*/
|
||||
this.isPlaying = false;
|
||||
|
||||
/**
|
||||
* @property _frameIndex
|
||||
* @private
|
||||
* @type {Number}
|
||||
* default 0
|
||||
*/
|
||||
this._frameIndex = 0;
|
||||
|
||||
/**
|
||||
* The currently displayed frame of the Animation.
|
||||
* @property currentFrame
|
||||
* @public
|
||||
* @type {Phaser.Animation.Frame}
|
||||
*/
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.prototype = {
|
||||
|
||||
/**
|
||||
* Play this animation.
|
||||
* @param frameRate {number} FrameRate you want to specify instead of using default.
|
||||
* @param loop {bool} Whether or not the animation is looped or just plays once.
|
||||
/**
|
||||
* Plays this animation.
|
||||
*
|
||||
* @method play
|
||||
* @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
* @return {Phaser.Animation} A reference to this Animation instance.
|
||||
*/
|
||||
play: function (frameRate, loop) {
|
||||
|
||||
|
@ -65,14 +148,20 @@ Phaser.Animation.prototype = {
|
|||
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
this._parent.events.onAnimationStart.dispatch(this._parent, this);
|
||||
|
||||
if (this._parent.events)
|
||||
{
|
||||
this._parent.events.onAnimationStart.dispatch(this._parent, this);
|
||||
}
|
||||
|
||||
return this;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Play this animation from the first frame.
|
||||
/**
|
||||
* Sets this animation back to the first frame and restarts the animation.
|
||||
*
|
||||
* @method restart
|
||||
*/
|
||||
restart: function () {
|
||||
|
||||
|
@ -88,12 +177,15 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop playing animation and set it finished.
|
||||
/**
|
||||
* Stops playback of this animation and set it to a finished state. If a resetFrame is provided it will stop playback and set frame to the first in the animation.
|
||||
*
|
||||
* @method stop
|
||||
* @param {Boolean} [resetFrame=false] If true after the animation stops the currentFrame value will be set to the first frame in this animation.
|
||||
*/
|
||||
stop: function (resetFrame) {
|
||||
|
||||
if (typeof resetFrame == 'undefined') { resetFrame = false; }
|
||||
if (typeof resetFrame === 'undefined') { resetFrame = false; }
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
|
@ -105,8 +197,10 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Update animation frames.
|
||||
/**
|
||||
* Updates this animation. Called automatically by the AnimationManager.
|
||||
*
|
||||
* @method update
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
|
@ -144,8 +238,10 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Clean up animation memory.
|
||||
/**
|
||||
* Cleans up this animation ready for deletion. Nulls all values and references.
|
||||
*
|
||||
* @method destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
|
@ -158,14 +254,20 @@ Phaser.Animation.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Animation complete callback method.
|
||||
/**
|
||||
* Called internally when the animation finishes playback. Sets the isPlaying and isFinished states and dispatches the onAnimationComplete event if it exists on the parent.
|
||||
*
|
||||
* @method onComplete
|
||||
*/
|
||||
onComplete: function () {
|
||||
|
||||
this.isPlaying = false;
|
||||
this.isFinished = true;
|
||||
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
|
||||
|
||||
if (this._parent.events)
|
||||
{
|
||||
this._parent.events.onAnimationComplete.dispatch(this._parent, this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -173,6 +275,10 @@ Phaser.Animation.prototype = {
|
|||
|
||||
Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
|
||||
|
||||
/**
|
||||
* @method frameTotal
|
||||
* @return {Number} The total number of frames in this animation.
|
||||
*/
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
@ -181,6 +287,10 @@ Object.defineProperty(Phaser.Animation.prototype, "frameTotal", {
|
|||
|
||||
Object.defineProperty(Phaser.Animation.prototype, "frame", {
|
||||
|
||||
/**
|
||||
* @method frame
|
||||
* @return {Animation.Frame} Returns the current frame, or if not set the index of the most recent frame.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame !== null)
|
||||
|
@ -194,6 +304,10 @@ Object.defineProperty(Phaser.Animation.prototype, "frame", {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* @method frame
|
||||
* @return {Number} Sets the current frame to the given frame index and updates the texture cache.
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
this.currentFrame = this._frameData.getFrame(value);
|
||||
|
|
|
@ -1,44 +1,89 @@
|
|||
/**
|
||||
* AnimationManager
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
* The AnimationManager is used to add, play and update Phaser Animations.
|
||||
* Any Game Object such as Phaser.Sprite that supports animation contains a single AnimationManager instance.
|
||||
*
|
||||
* Any Game Object that supports animation contains a single AnimationManager instance. It is used to add,
|
||||
* play and update Phaser.Animation objects.
|
||||
*
|
||||
* @package Phaser.Components.AnimationManager
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @class AnimationManager
|
||||
* @constructor
|
||||
* @param {Phaser.Sprite} sprite A reference to the Game Object that owns this AnimationManager.
|
||||
*/
|
||||
Phaser.AnimationManager = function (sprite) {
|
||||
|
||||
/**
|
||||
* Data contains animation frames.
|
||||
* @type {FrameData}
|
||||
*/
|
||||
this._frameData = null;
|
||||
|
||||
/**
|
||||
* Keeps track of the current frame of the animation.
|
||||
*/
|
||||
this.currentFrame = null;
|
||||
|
||||
/**
|
||||
* A reference to the parent Sprite that owns this AnimationManager.
|
||||
* @property sprite
|
||||
* @public
|
||||
* @type {Phaser.Sprite}
|
||||
*/
|
||||
this.sprite = sprite;
|
||||
|
||||
/**
|
||||
* A reference to the currently running Game.
|
||||
* @property game
|
||||
* @public
|
||||
* @type {Phaser.Game}
|
||||
*/
|
||||
this.game = sprite.game;
|
||||
|
||||
/**
|
||||
* The currently displayed Frame of animation, if any.
|
||||
* @property currentFrame
|
||||
* @public
|
||||
* @type {Phaser.Animation.Frame}
|
||||
*/
|
||||
this.currentFrame = null;
|
||||
|
||||
/**
|
||||
* Should the animation data continue to update even if the Sprite.visible is set to false.
|
||||
* @property updateIfVisible
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
* @default true
|
||||
*/
|
||||
this.updateIfVisible = true;
|
||||
|
||||
/**
|
||||
* A temp. var for holding the currently playing Animations FrameData.
|
||||
* @property _frameData
|
||||
* @private
|
||||
* @type {Phaser.Animation.FrameData}
|
||||
*/
|
||||
this._frameData = null;
|
||||
|
||||
/**
|
||||
* An internal object that stores all of the Animation instances.
|
||||
* @property _anims
|
||||
* @private
|
||||
* @type {Object}
|
||||
*/
|
||||
this._anims = {};
|
||||
|
||||
this.updateIfVisible = true;
|
||||
/**
|
||||
* An internal object to help avoid gc.
|
||||
* @property _outputFrames
|
||||
* @private
|
||||
* @type {Object}
|
||||
*/
|
||||
this._outputFrames = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.AnimationManager.prototype = {
|
||||
|
||||
|
||||
/**
|
||||
* Load animation frame data.
|
||||
* @param frameData Data to be loaded.
|
||||
*/
|
||||
/**
|
||||
* Loads FrameData into the internal temporary vars and resets the frame index to zero.
|
||||
* This is called automatically when a new Sprite is created.
|
||||
*
|
||||
* @method loadFrameData
|
||||
* @private
|
||||
* @param {Phaser.Animation.FrameData} frameData The FrameData set to load.
|
||||
*/
|
||||
loadFrameData: function (frameData) {
|
||||
|
||||
this._frameData = frameData;
|
||||
|
@ -47,28 +92,30 @@ Phaser.AnimationManager.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Add a new animation.
|
||||
* @param name {string} What this animation should be called (e.g. "run").
|
||||
* @param frames {any[]} An array of numbers/strings indicating what frames to play in what order (e.g. [1, 2, 3] or ['run0', 'run1', run2]).
|
||||
* @param frameRate {number} The speed in frames per second that the animation should play at (e.g. 60 fps).
|
||||
* @param loop {bool} Whether or not the animation is looped or just plays once.
|
||||
* @param useNumericIndex {bool} Use number indexes instead of string indexes?
|
||||
* @return {Animation} The Animation that was created
|
||||
* Adds a new animation under the given key. Optionally set the frames, frame rate and loop.
|
||||
* Animations added in this way are played back with the play function.
|
||||
*
|
||||
* @method add
|
||||
* @param {String} name The unique (within this Sprite) name for the animation, i.e. "run", "fire", "walk".
|
||||
* @param {Array} [frames=null] An array of numbers/strings that correspond to the frames to add to this animation and in which order. e.g. [1, 2, 3] or ['run0', 'run1', run2]). If null then all frames will be used.
|
||||
* @param {Number} [frameRate=60] The speed at which the animation should play. The speed is given in frames per second.
|
||||
* @param {Boolean} [loop=false] {bool} Whether or not the animation is looped or just plays once.
|
||||
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @return {Phaser.Animation} The Animation object that was created.
|
||||
*/
|
||||
add: function (name, frames, frameRate, loop, useNumericIndex) {
|
||||
|
||||
frames = frames || null;
|
||||
frameRate = frameRate || 60;
|
||||
|
||||
if (typeof loop == 'undefined') { loop = false; }
|
||||
if (typeof useNumericIndex == 'undefined') { useNumericIndex = true; }
|
||||
|
||||
if (this._frameData == null)
|
||||
{
|
||||
console.warn('No frameData available for Phaser.Animation ' + name);
|
||||
console.warn('No FrameData available for Phaser.Animation ' + name);
|
||||
return;
|
||||
}
|
||||
|
||||
frameRate = frameRate || 60;
|
||||
|
||||
if (typeof loop === 'undefined') { loop = false; }
|
||||
if (typeof useNumericIndex === 'undefined') { useNumericIndex = true; }
|
||||
|
||||
// Create the signals the AnimationManager will emit
|
||||
if (this.sprite.events.onAnimationStart == null)
|
||||
{
|
||||
|
@ -77,25 +124,11 @@ Phaser.AnimationManager.prototype = {
|
|||
this.sprite.events.onAnimationLoop = new Phaser.Signal();
|
||||
}
|
||||
|
||||
if (frames == null)
|
||||
{
|
||||
frames = this._frameData.getFrameIndexes();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.validateFrames(frames, useNumericIndex) == false)
|
||||
{
|
||||
console.warn('Invalid frames given to Phaser.Animation ' + name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._outputFrames.length = 0;
|
||||
|
||||
if (useNumericIndex == false)
|
||||
{
|
||||
frames = this._frameData.getFrameIndexesByName(frames);
|
||||
}
|
||||
this._frameData.getFrameIndexes(frames, useNumericIndex, this._outputFrames);
|
||||
|
||||
this._anims[name] = new Phaser.Animation(this.game, this.sprite, this._frameData, name, frames, frameRate, loop);
|
||||
this._anims[name] = new Phaser.Animation(this.game, this.sprite, name, this._frameData, this._outputFrames, frameRate, loop);
|
||||
this.currentAnim = this._anims[name];
|
||||
this.currentFrame = this.currentAnim.currentFrame;
|
||||
this.sprite.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
@ -105,10 +138,12 @@ Phaser.AnimationManager.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Check whether the frames is valid.
|
||||
* @param frames {any[]} Frames to be validated.
|
||||
* @param useNumericIndex {bool} Does these frames use number indexes or string indexes?
|
||||
* @return {bool} True if they're valid, otherwise return false.
|
||||
* Check whether the frames in the given array are valid and exist.
|
||||
*
|
||||
* @method validateFrames
|
||||
* @param {Array} frames An array of frames to be validated.
|
||||
* @param {Boolean} [useNumericIndex=true] Validate the frames based on their numeric index (true) or string index (false)
|
||||
* @return {Boolean} True if all given Frames are valid, otherwise false.
|
||||
*/
|
||||
validateFrames: function (frames, useNumericIndex) {
|
||||
|
||||
|
@ -137,16 +172,17 @@ Phaser.AnimationManager.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Play animation with specific name.
|
||||
* @param name {string} The string name of the animation you want to play.
|
||||
* @param frameRate {number} FrameRate you want to specify instead of using default.
|
||||
* @param loop {bool} Whether or not the animation is looped or just plays once.
|
||||
* Play an animation based on the given key. The animation should previously have been added via sprite.animations.add()
|
||||
* If the requested animation is already playing this request will be ignored. If you need to reset an already running animation do so directly on the Animation object itself.
|
||||
*
|
||||
* @method play
|
||||
* @param {String} name The name of the animation to be played, e.g. "fire", "walk", "jump".
|
||||
* @param {Number} [frameRate=null] The framerate to play the animation at. The speed is given in frames per second. If not provided the previously set frameRate of the Animation is used.
|
||||
* @param {Boolean} [loop=null] Should the animation be looped after playback. If not provided the previously set loop value of the Animation is used.
|
||||
* @return {Phaser.Animation} A reference to playing Animation instance.
|
||||
*/
|
||||
play: function (name, frameRate, loop) {
|
||||
|
||||
frameRate = frameRate || null;
|
||||
loop = loop || null;
|
||||
|
||||
if (this._anims[name])
|
||||
{
|
||||
if (this.currentAnim == this._anims[name])
|
||||
|
@ -166,8 +202,12 @@ Phaser.AnimationManager.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Stop animation. If a name is given that specific animation is stopped, otherwise the current one is stopped.
|
||||
* Current animation will be automatically set to the stopped one.
|
||||
* Stop playback of an animation. If a name is given that specific animation is stopped, otherwise the current animation is stopped.
|
||||
* The currentAnim property of the AnimationManager is automatically set to the animation given.
|
||||
*
|
||||
* @method stop
|
||||
* @param {String} [name=null] The name of the animation to be stopped, e.g. "fire". If none is given the currently running animation is stopped.
|
||||
* @param {Boolean} [resetFrame=false] When the animation is stopped should the currentFrame be set to the first frame of the animation (true) or paused on the last frame displayed (false)
|
||||
*/
|
||||
stop: function (name, resetFrame) {
|
||||
|
||||
|
@ -192,8 +232,11 @@ Phaser.AnimationManager.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Update animation and parent sprite's bounds.
|
||||
* Returns true if a new frame has been set, otherwise false.
|
||||
* The main update function is called by the Sprites update loop. It's responsible for updating animation frames and firing related events.
|
||||
*
|
||||
* @method update
|
||||
* @protected
|
||||
* @return {Boolean} True if a new animation frame has been set, otherwise false.
|
||||
*/
|
||||
update: function () {
|
||||
|
||||
|
@ -213,8 +256,10 @@ Phaser.AnimationManager.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes all related references
|
||||
/**
|
||||
* Destroys all references this AnimationManager contains. Sets the _anims to a new object and nulls the current animation.
|
||||
*
|
||||
* @method destroy
|
||||
*/
|
||||
destroy: function () {
|
||||
|
||||
|
@ -230,6 +275,10 @@ Phaser.AnimationManager.prototype = {
|
|||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
|
||||
|
||||
/**
|
||||
* @method frameData
|
||||
* @return {Phaser.Animation.FrameData} Returns the FrameData of the current animation.
|
||||
*/
|
||||
get: function () {
|
||||
return this._frameData;
|
||||
}
|
||||
|
@ -238,6 +287,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameData", {
|
|||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
||||
|
||||
/**
|
||||
* @method frameTotal
|
||||
* @return {Number} Returns the total number of frames in the loaded FrameData, or -1 if no FrameData is loaded.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
if (this._frameData)
|
||||
|
@ -254,6 +307,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameTotal", {
|
|||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
||||
|
||||
/**
|
||||
* @method frame
|
||||
* @return {Number} Returns the index of the current frame.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame)
|
||||
|
@ -264,8 +321,8 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
|||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param value
|
||||
* @method frame
|
||||
* @param {Number} value Sets the current frame on the Sprite and updates the texture cache for display.
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
|
@ -283,6 +340,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frame", {
|
|||
|
||||
Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
||||
|
||||
/**
|
||||
* @method frameName
|
||||
* @return {String} Returns the name of the current frame if it has one.
|
||||
*/
|
||||
get: function () {
|
||||
|
||||
if (this.currentFrame)
|
||||
|
@ -292,6 +353,10 @@ Object.defineProperty(Phaser.AnimationManager.prototype, "frameName", {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* @method frameName
|
||||
* @param {String} value Sets the current frame on the Sprite and updates the texture cache for display.
|
||||
*/
|
||||
set: function (value) {
|
||||
|
||||
if (this._frameData && this._frameData.getFrameByName(value))
|
||||
|
|
|
@ -1,123 +1,181 @@
|
|||
/**
|
||||
* Frame
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
|
||||
/**
|
||||
* A Frame is a single frame of an animation and is part of a FrameData collection.
|
||||
*
|
||||
* @package Phaser.Animation.Frame
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @class Frame
|
||||
* @constructor
|
||||
* @param {Number} index The index of this Frame within the FrameData set it is being added to.
|
||||
* @param {Number} x X position of the frame within the texture image.
|
||||
* @param {Number} y Y position of the frame within the texture image.
|
||||
* @param {Number} width Width of the frame within the texture image.
|
||||
* @param {Number} height Height of the frame within the texture image.
|
||||
* @param {String} name The name of the frame. In Texture Atlas data this is usually set to the filename.
|
||||
* @param {String} uuid Internal UUID key.
|
||||
*/
|
||||
Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
||||
Phaser.Animation.Frame = function (index, x, y, width, height, name, uuid) {
|
||||
|
||||
/**
|
||||
* X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
* The index of this Frame within the FrameData set it is being added to.
|
||||
* @property index
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.index = index;
|
||||
|
||||
/**
|
||||
* X position within the image to cut from.
|
||||
* @property x
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.x = x;
|
||||
|
||||
/**
|
||||
* Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
* Y position within the image to cut from.
|
||||
* @property y
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.y = y;
|
||||
|
||||
/**
|
||||
* Width of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the frame.
|
||||
* @property width
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.width = width;
|
||||
|
||||
/**
|
||||
* Height of the frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the frame.
|
||||
* @property height
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.height = height;
|
||||
|
||||
/**
|
||||
* center X position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @type {number}
|
||||
*/
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* Useful for Sprite Sheets.
|
||||
* @type {number}
|
||||
*/
|
||||
this.index = 0;
|
||||
|
||||
/**
|
||||
* Useful for Texture Atlas files. (is set to the filename value)
|
||||
*/
|
||||
* Useful for Texture Atlas files. (is set to the filename value)
|
||||
* @property name
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.name = name;
|
||||
|
||||
/**
|
||||
* A link to the PIXI.TextureCache entry
|
||||
*/
|
||||
* A link to the PIXI.TextureCache entry
|
||||
* @property uuid
|
||||
* @public
|
||||
* @type {String}
|
||||
*/
|
||||
this.uuid = uuid;
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @type {number}
|
||||
*/
|
||||
* center X position within the image to cut from.
|
||||
* @property centerX
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.centerX = Math.floor(width / 2);
|
||||
|
||||
/**
|
||||
* center Y position within the image to cut from.
|
||||
* @property centerY
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.centerY = Math.floor(height / 2);
|
||||
|
||||
/**
|
||||
* The distance from the top left to the bottom-right of this Frame.
|
||||
* @property distance
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.distance = Phaser.Math.distance(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* Rotated? (not yet implemented)
|
||||
*/
|
||||
* Rotated? (not yet implemented)
|
||||
* @property rotated
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
* @default false
|
||||
*/
|
||||
this.rotated = false;
|
||||
|
||||
/**
|
||||
* Either cw or ccw, rotation is always 90 degrees.
|
||||
*/
|
||||
* Either cw or ccw, rotation is always 90 degrees.
|
||||
* @property rotationDirection
|
||||
* @public
|
||||
* @type {String}
|
||||
* @default "cw"
|
||||
*/
|
||||
this.rotationDirection = 'cw';
|
||||
|
||||
/**
|
||||
* Was it trimmed when packed?
|
||||
* @type {bool}
|
||||
*/
|
||||
* Was it trimmed when packed?
|
||||
* @property trimmed
|
||||
* @public
|
||||
* @type {Boolean}
|
||||
*/
|
||||
this.trimmed = false;
|
||||
|
||||
/**
|
||||
* Width of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the original sprite.
|
||||
* @property sourceSizeW
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.sourceSizeW = width;
|
||||
|
||||
/**
|
||||
* Height of the original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the original sprite.
|
||||
* @property sourceSizeH
|
||||
* @public
|
||||
* @type {Number}
|
||||
*/
|
||||
this.sourceSizeH = height;
|
||||
|
||||
/**
|
||||
* X position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* X position of the trimmed sprite inside original sprite.
|
||||
* @property spriteSourceSizeX
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeX = 0;
|
||||
|
||||
/**
|
||||
* Y position of the trimmed sprite inside original sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Y position of the trimmed sprite inside original sprite.
|
||||
* @property spriteSourceSizeY
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeY = 0;
|
||||
|
||||
/**
|
||||
* Width of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Width of the trimmed sprite.
|
||||
* @property spriteSourceSizeW
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeW = 0;
|
||||
|
||||
/**
|
||||
* Height of the trimmed sprite.
|
||||
* @type {number}
|
||||
*/
|
||||
* Height of the trimmed sprite.
|
||||
* @property spriteSourceSizeH
|
||||
* @public
|
||||
* @type {Number}
|
||||
* @default 0
|
||||
*/
|
||||
this.spriteSourceSizeH = 0;
|
||||
|
||||
};
|
||||
|
@ -125,14 +183,16 @@ Phaser.Animation.Frame = function (x, y, width, height, name, uuid) {
|
|||
Phaser.Animation.Frame.prototype = {
|
||||
|
||||
/**
|
||||
* Set trim of the frame.
|
||||
* @param trimmed {bool} Whether this frame trimmed or not.
|
||||
* @param actualWidth {number} Actual width of this frame.
|
||||
* @param actualHeight {number} Actual height of this frame.
|
||||
* @param destX {number} Destination x position.
|
||||
* @param destY {number} Destination y position.
|
||||
* @param destWidth {number} Destination draw width.
|
||||
* @param destHeight {number} Destination draw height.
|
||||
* If the frame was trimmed when added to the Texture Atlas this records the trim and source data.
|
||||
*
|
||||
* @method setTrim
|
||||
* @param {Boolean} trimmed If this frame was trimmed or not.
|
||||
* @param {Number} actualWidth The width of the frame before being trimmed.
|
||||
* @param {Number} actualHeight The height of the frame before being trimmed.
|
||||
* @param {Number} destX The destination X position of the trimmed frame for display.
|
||||
* @param {Number} destY The destination Y position of the trimmed frame for display.
|
||||
* @param {Number} destWidth The destination width of the trimmed frame for display.
|
||||
* @param {Number} destHeight The destination height of the trimmed frame for display.
|
||||
*/
|
||||
setTrim: function (trimmed, actualWidth, actualHeight, destX, destY, destWidth, destHeight) {
|
||||
|
||||
|
|
|
@ -1,37 +1,45 @@
|
|||
/**
|
||||
* FrameData
|
||||
*
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation.FrameData
|
||||
*/
|
||||
|
||||
/**
|
||||
* FrameData is a container for Frame objects, which are the internal representation of animation data in Phaser.
|
||||
*
|
||||
* @package Phaser.Animation.FrameData
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @class FrameData
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.Animation.FrameData = function () {
|
||||
|
||||
/**
|
||||
* Local frame container.
|
||||
* @type {Phaser.Frame[]}
|
||||
* @private
|
||||
*/
|
||||
* Local array of frames.
|
||||
* @property _frames
|
||||
* @private
|
||||
* @type {Array}
|
||||
*/
|
||||
this._frames = [];
|
||||
|
||||
/**
|
||||
* Local frameName<->index container.
|
||||
* @private
|
||||
*/
|
||||
* Local array of frame names for name to index conversions.
|
||||
* @property _frameNames
|
||||
* @private
|
||||
* @type {Array}
|
||||
*/
|
||||
this._frameNames = [];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Animation.FrameData.prototype = {
|
||||
|
||||
/**
|
||||
* Add a new frame.
|
||||
* @param frame {Frame} The frame you want to add.
|
||||
* @return {Frame} The frame you just added.
|
||||
*/
|
||||
/**
|
||||
* Adds a new Frame to this FrameData collection. Typically called by the Animation.Parser and not directly.
|
||||
*
|
||||
* @method addFrame
|
||||
* @param {Phaser.Animation.Frame} frame The frame to add to this FrameData set.
|
||||
* @return {Phaser.Animation.Frame} The frame that was just added.
|
||||
*/
|
||||
addFrame: function (frame) {
|
||||
|
||||
frame.index = this._frames.length;
|
||||
|
@ -48,9 +56,11 @@ Phaser.Animation.FrameData.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get a frame by its index.
|
||||
* @param index {number} Index of the frame you want to get.
|
||||
* @return {Frame} The frame you want.
|
||||
* Get a Frame by its numerical index.
|
||||
*
|
||||
* @method getFrame
|
||||
* @param {Number} index The index of the frame you want to get.
|
||||
* @return {Phaser.Animation.Frame} The frame, if found.
|
||||
*/
|
||||
getFrame: function (index) {
|
||||
|
||||
|
@ -63,14 +73,16 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get a frame by its name.
|
||||
* @param name {string} Name of the frame you want to get.
|
||||
* @return {Frame} The frame you want.
|
||||
*/
|
||||
/**
|
||||
* Get a Frame by its frame name.
|
||||
*
|
||||
* @method getFrameByName
|
||||
* @param {String} name The name of the frame you want to get.
|
||||
* @return {Phaser.Animation.Frame} The frame, if found.
|
||||
*/
|
||||
getFrameByName: function (name) {
|
||||
|
||||
if (this._frameNames[name] !== '')
|
||||
if (this._frameNames[name] && this._frameNames[name] !== '')
|
||||
{
|
||||
return this._frames[this._frameNames[name]];
|
||||
}
|
||||
|
@ -79,11 +91,13 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether there's a frame with given name.
|
||||
* @param name {string} Name of the frame you want to check.
|
||||
* @return {bool} True if frame with given name found, otherwise return false.
|
||||
*/
|
||||
/**
|
||||
* Check if there is a Frame with the given name.
|
||||
*
|
||||
* @method checkFrameName
|
||||
* @param {String} name The name of the frame you want to check.
|
||||
* @return {Boolean} True if the frame is found, otherwise false.
|
||||
*/
|
||||
checkFrameName: function (name) {
|
||||
|
||||
if (this._frameNames[name] == null)
|
||||
|
@ -96,11 +110,13 @@ Phaser.Animation.FrameData.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get ranges of frames in an array.
|
||||
* @param start {number} Start index of frames you want.
|
||||
* @param end {number} End index of frames you want.
|
||||
* @param [output] {Frame[]} result will be added into this array.
|
||||
* @return {Frame[]} Ranges of specific frames in an array.
|
||||
* Returns a range of frames based on the given start and end frame indexes and returns them in an Array.
|
||||
*
|
||||
* @method getFrameRange
|
||||
* @param {Number} start The starting frame index.
|
||||
* @param {Number} end The ending frame index.
|
||||
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array.
|
||||
* @return {Array} An array of Frames between the start and end index values, or an empty array if none were found.
|
||||
*/
|
||||
getFrameRange: function (start, end, output) {
|
||||
|
||||
|
@ -116,37 +132,45 @@ Phaser.Animation.FrameData.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Get all indexes of frames by giving their name.
|
||||
* @param [output] {number[]} result will be added into this array.
|
||||
* @return {number[]} Indexes of specific frames in an array.
|
||||
* Returns all of the Frames in this FrameData set where the frame index is found in the input array.
|
||||
* The frames are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method getFrames
|
||||
* @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created.
|
||||
* @return {Array} An array of all Frames in this FrameData set matching the given names or IDs.
|
||||
*/
|
||||
getFrameIndexes: function (output) {
|
||||
getFrames: function (frames, useNumericIndex, output) {
|
||||
|
||||
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
if (typeof frames === "undefined" || frames.length == 0)
|
||||
{
|
||||
output.push(i);
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the frame indexes by giving the frame names.
|
||||
* @param [output] {number[]} result will be added into this array.
|
||||
* @return {number[]} Names of specific frames in an array.
|
||||
*/
|
||||
getFrameIndexesByName: function (input) {
|
||||
|
||||
var output = [];
|
||||
|
||||
for (var i = 0; i < input.length; i++)
|
||||
{
|
||||
if (this.getFrameByName(input[i]))
|
||||
// No input array, so we loop through all frames
|
||||
for (var i = 0; i < this._frames.length; i++)
|
||||
{
|
||||
output.push(this.getFrameByName(input[i]).index);
|
||||
// We only need the indexes
|
||||
output.push(this._frames[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input array given, loop through that instead
|
||||
for (var i = 0, len = frames.length; i < len; i++)
|
||||
{
|
||||
// Does the input array contain names or indexes?
|
||||
if (useNumericIndex)
|
||||
{
|
||||
// The actual frame
|
||||
output.push(this.getFrame(input[i]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// The actual frame
|
||||
output.push(this.getFrameByName(input[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,35 +178,60 @@ Phaser.Animation.FrameData.prototype = {
|
|||
|
||||
},
|
||||
|
||||
/**
|
||||
* Get all frames in this frame data.
|
||||
* @return {Frame[]} All the frames in an array.
|
||||
*/
|
||||
getAllFrames: function () {
|
||||
return this._frames;
|
||||
},
|
||||
/**
|
||||
* Returns all of the Frame indexes in this FrameData set.
|
||||
* The frames indexes are returned in the output array, or if none is provided in a new Array object.
|
||||
*
|
||||
* @method getFrameIndexes
|
||||
* @param {Array} frames An Array containing the indexes of the frames to retrieve. If the array is empty then all frames in the FrameData are returned.
|
||||
* @param {Boolean} [useNumericIndex=true] Are the given frames using numeric indexes (default) or strings? (false)
|
||||
* @param {Array} [output] Optional array. If given the results will be appended to the end of this Array, otherwise a new array is created.
|
||||
* @return {Array} An array of all Frame indexes matching the given names or IDs.
|
||||
*/
|
||||
getFrameIndexes: function (input, useNumericIndex, output) {
|
||||
|
||||
/**
|
||||
* Get All frames with specific ranges.
|
||||
* @param range {number[]} Ranges in an array.
|
||||
* @return {Frame[]} All frames in an array.
|
||||
*/
|
||||
getFrames: function (range) {
|
||||
if (typeof useNumericIndex === "undefined") { useNumericIndex = true; }
|
||||
if (typeof output === "undefined") { output = []; }
|
||||
|
||||
var output = [];
|
||||
|
||||
for (var i = 0; i < range.length; i++)
|
||||
if (typeof frames === "undefined" || frames.length == 0)
|
||||
{
|
||||
output.push(this._frames[i]);
|
||||
// No input array, so we loop through all frames
|
||||
for (var i = 0, len = this._frames.length; i < len; i++)
|
||||
{
|
||||
output.push(this._frames[i].index);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input array given, loop through that instead
|
||||
for (var i = 0, len = input.length; i < len; i++)
|
||||
{
|
||||
// Does the input array contain names or indexes?
|
||||
if (useNumericIndex)
|
||||
{
|
||||
output.push(input[i].index);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.push(this.getFrameByName(input[i]).index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Object.defineProperty(Phaser.Animation.FrameData.prototype, "total", {
|
||||
|
||||
/**
|
||||
* Returns the total number of frames in this FrameData set.
|
||||
*
|
||||
* @method total
|
||||
* @return {Number} The total number of frames in this FrameData set.
|
||||
*/
|
||||
get: function () {
|
||||
return this._frames.length;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
/**
|
||||
* Animation Parser
|
||||
*
|
||||
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
|
||||
*
|
||||
* @package Phaser.Animation.Parser
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @module Phaser.Animation
|
||||
*/
|
||||
|
||||
Phaser.Animation.Parser = {
|
||||
|
||||
/**
|
||||
* Parse a sprite sheet from asset data.
|
||||
* @param key {string} Asset key for the sprite sheet data.
|
||||
* @param frameWidth {number} Width of animation frame.
|
||||
* @param frameHeight {number} Height of animation frame.
|
||||
* @param frameMax {number} Number of animation frames.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
*/
|
||||
/**
|
||||
* Parse a Sprite Sheet and extract the animation frame data from it.
|
||||
*
|
||||
* @method spriteSheet
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {String} key The Game.Cache asset key of the Sprite Sheet image.
|
||||
* @param {Number} frameWidth The fixed width of each frame of the animation.
|
||||
* @param {Number} frameHeight The fixed height of each frame of the animation.
|
||||
* @param {Number} [frameMax=-1] The total number of animation frames to extact from the Sprite Sheet. The default value of -1 means "extract all frames".
|
||||
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
spriteSheet: function (game, key, frameWidth, frameHeight, frameMax) {
|
||||
|
||||
// How big is our image?
|
||||
|
@ -55,7 +57,7 @@ Phaser.Animation.Parser = {
|
|||
{
|
||||
var uuid = game.rnd.uuid();
|
||||
|
||||
data.addFrame(new Phaser.Animation.Frame(x, y, frameWidth, frameHeight, '', uuid));
|
||||
data.addFrame(new Phaser.Animation.Frame(i, x, y, frameWidth, frameHeight, '', uuid));
|
||||
|
||||
PIXI.TextureCache[uuid] = new PIXI.Texture(PIXI.BaseTextureCache[key], {
|
||||
x: x,
|
||||
|
@ -78,9 +80,13 @@ Phaser.Animation.Parser = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Parse frame data from json texture atlas in Array format.
|
||||
* @param json {object} Json data you want to parse.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method JSONData
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {Object} json The JSON data from the Texture Atlas. Must be in Array format.
|
||||
* @param {String} cacheKey The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
JSONData: function (game, json, cacheKey) {
|
||||
|
||||
|
@ -104,6 +110,7 @@ Phaser.Animation.Parser = {
|
|||
var uuid = game.rnd.uuid();
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Animation.Frame(
|
||||
i,
|
||||
frames[i].frame.x,
|
||||
frames[i].frame.y,
|
||||
frames[i].frame.w,
|
||||
|
@ -141,9 +148,13 @@ Phaser.Animation.Parser = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Parse frame data from json texture atlas in Hash format.
|
||||
* @param json {object} Json data you want to parse.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
* Parse the JSON data and extract the animation frame data from it.
|
||||
*
|
||||
* @method JSONDataHash
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {Object} json The JSON data from the Texture Atlas. Must be in JSON Hash format.
|
||||
* @param {String} cacheKey The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
JSONDataHash: function (game, json, cacheKey) {
|
||||
|
||||
|
@ -161,13 +172,14 @@ Phaser.Animation.Parser = {
|
|||
// By this stage frames is a fully parsed array
|
||||
var frames = json['frames'];
|
||||
var newFrame;
|
||||
var i = 0;
|
||||
|
||||
for (var key in frames)
|
||||
{
|
||||
console.log(key);
|
||||
var uuid = game.rnd.uuid();
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Animation.Frame(
|
||||
i,
|
||||
frames[key].frame.x,
|
||||
frames[key].frame.y,
|
||||
frames[key].frame.w,
|
||||
|
@ -198,6 +210,8 @@ Phaser.Animation.Parser = {
|
|||
PIXI.TextureCache[uuid].realSize = frames[key].spriteSourceSize;
|
||||
PIXI.TextureCache[uuid].trim.x = 0;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -205,9 +219,13 @@ Phaser.Animation.Parser = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Parse frame data from an XML file.
|
||||
* @param xml {object} XML data you want to parse.
|
||||
* @return {FrameData} Generated FrameData object.
|
||||
* Parse the XML data and extract the animation frame data from it.
|
||||
*
|
||||
* @method XMLData
|
||||
* @param {Phaser.Game} game A reference to the currently running game.
|
||||
* @param {Object} xml The XML data from the Texture Atlas. Must be in Starling XML format.
|
||||
* @param {String} cacheKey The Game.Cache asset key of the texture image.
|
||||
* @return {Phaser.Animation.FrameData} A FrameData object containing the parsed frames.
|
||||
*/
|
||||
XMLData: function (game, xml, cacheKey) {
|
||||
|
||||
|
@ -230,6 +248,7 @@ Phaser.Animation.Parser = {
|
|||
var frame = frames[i].attributes;
|
||||
|
||||
newFrame = data.addFrame(new Phaser.Animation.Frame(
|
||||
i,
|
||||
frame.x.nodeValue,
|
||||
frame.y.nodeValue,
|
||||
frame.width.nodeValue,
|
||||
|
|
|
@ -361,8 +361,8 @@ Phaser.StateManager.prototype = {
|
|||
if (this._created == false && this.onCreateCallback)
|
||||
{
|
||||
// console.log('Create callback found');
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
this._created = true;
|
||||
this.onCreateCallback.call(this.callbackContext);
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -19,10 +19,13 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
|||
|
||||
PIXI.BitmapText.call(this, text, style);
|
||||
|
||||
this.type = Phaser.BITMAPTEXT;
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
this.anchor = new Phaser.Point();
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// Influence of camera movement upon the position
|
||||
|
@ -51,11 +54,10 @@ Phaser.BitmapText = function (game, x, y, text, style) {
|
|||
|
||||
};
|
||||
|
||||
Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
|
||||
Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype);
|
||||
// Phaser.BitmapText.prototype = Phaser.Utils.extend(true, PIXI.BitmapText.prototype);
|
||||
Phaser.BitmapText.prototype.constructor = Phaser.BitmapText;
|
||||
|
||||
// Add our own custom methods
|
||||
|
||||
/**
|
||||
* Automatically called by World.update
|
||||
*/
|
||||
|
|
|
@ -5,31 +5,112 @@ Phaser.Text = function (game, x, y, text, style) {
|
|||
text = text || '';
|
||||
style = style || '';
|
||||
|
||||
// If exists = false then the Sprite isn't updated by the core game loop or physics subsystem at all
|
||||
this.exists = true;
|
||||
|
||||
// This is a handy little var your game can use to determine if a sprite is alive or not, it doesn't effect rendering
|
||||
this.alive = true;
|
||||
|
||||
this.group = null;
|
||||
|
||||
this.name = '';
|
||||
|
||||
this.game = game;
|
||||
|
||||
PIXI.Text.call(this, text, style);
|
||||
|
||||
/*
|
||||
this.canvas = document.createElement("canvas");
|
||||
this.context = this.canvas.getContext("2d");
|
||||
|
||||
var canvasID = game.rnd.uuid();
|
||||
|
||||
PIXI.TextureCache[canvasID] = new PIXI.Texture(new PIXI.BaseTexture(this.canvas));
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, canvasID);
|
||||
|
||||
this.type = Phaser.TEXT;
|
||||
|
||||
this.setText(text);
|
||||
this.setStyle(style);
|
||||
|
||||
this.updateText();
|
||||
this.dirty = false;
|
||||
*/
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
// Replaces the PIXI.Point with a slightly more flexible one
|
||||
this.anchor = new Phaser.Point();
|
||||
this.scale = new Phaser.Point(1, 1);
|
||||
|
||||
// Influence of camera movement upon the position
|
||||
this.scrollFactor = new Phaser.Point(1, 1);
|
||||
|
||||
// A mini cache for storing all of the calculated values
|
||||
this._cache = {
|
||||
|
||||
dirty: false,
|
||||
|
||||
// Transform cache
|
||||
a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1,
|
||||
|
||||
// The previous calculated position inc. camera x/y and scrollFactor
|
||||
x: -1, y: -1,
|
||||
|
||||
// The actual scale values based on the worldTransform
|
||||
scaleX: 1, scaleY: 1
|
||||
|
||||
};
|
||||
|
||||
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
|
||||
this.renderable = true;
|
||||
|
||||
};
|
||||
|
||||
// Phaser.Text.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Text.prototype);
|
||||
Phaser.Text.prototype = Phaser.Utils.extend(true, PIXI.Text.prototype);
|
||||
Phaser.Text.prototype = Object.create(PIXI.Text.prototype);
|
||||
Phaser.Text.prototype.constructor = Phaser.Text;
|
||||
|
||||
// Add our own custom methods
|
||||
// Automatically called by World.update
|
||||
Phaser.Text.prototype.update = function() {
|
||||
|
||||
if (!this.exists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this._cache.dirty = false;
|
||||
|
||||
this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x);
|
||||
this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y);
|
||||
|
||||
if (this.position.x != this._cache.x || this.position.y != this._cache.y)
|
||||
{
|
||||
this.position.x = this._cache.x;
|
||||
this.position.y = this._cache.y;
|
||||
this._cache.dirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.Text.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
return Phaser.Math.radToDeg(this.rotation);
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.rotation = Phaser.Math.degToRad(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Text.prototype, 'x', {
|
||||
|
||||
get: function() {
|
||||
return this.position.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Text.prototype, 'y', {
|
||||
|
||||
get: function() {
|
||||
return this.position.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.position.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -69,6 +69,9 @@ Phaser.Utils = {
|
|||
|
||||
// deep, target, objects to copy to the target object
|
||||
// This is a slightly modified version of jQuery.extend (http://api.jquery.com/jQuery.extend/)
|
||||
// deep (boolean)
|
||||
// target (object to add to)
|
||||
// objects ... (objects to recurse and copy from)
|
||||
extend: function () {
|
||||
|
||||
var options, name, src, copy, copyIsArray, clone,
|
||||
|
|
Loading…
Reference in a new issue