854 Commits
Author SHA1 Message Date
photonstorm de3583db80 Version 1.1.6 - "Shienar" - 24th February 2014
New Examples:

* Added lovely new little mini golf game by jpcloud.

Updates:

* Loader can now load JSON files natively (thanks lucas)
* TilemapParser now errors if the tileset isn't the right size

Bug Fixes:

* Updated Physics.Body.applyDamping so that velocity is reduced down to zero properly (thanks caezs)
* ArcadePhysics.collideSpriteVsTilemapLayer wouldn't call the process or collide callbacks if only 1 tile was involved in the check (thanks mandarinx)
* Lots of documentation fixes (thanks nhowell)
* Fix for PixiPatch so it renders masks again (thanks georgios)
* Modified ArcadePhysics.intersects so it returns a value as well as asigns (thanks bunnyhero)
* Lots of TypeScript defs fixes (thanks clark)
2014-02-24 01:32:20 +00:00
photonstorm 88f901249a Final 1.1.6 package files. 2014-02-24 01:29:32 +00:00
photonstorm f4ff4d88fe 1.1.6 release. The final of the 1.1 branch. 2014-02-24 01:28:13 +00:00
Richard Davey 37323562cd Merge pull request #469 from bburky/cdnjs-1.1.5
Update CDNJS link for 1.1.5
2014-02-21 23:43:28 +00:00
Blake Burkhart f6cc40f025 Update CDNJS link for 1.1.5 2014-02-21 17:21:16 -06:00
Richard Davey 529d210006 Merge pull request #329 from lucasmonteverde/dev
Custom JSON loader
2014-02-21 18:42:01 +00:00
Richard Davey 7b572b9b81 Merge pull request #377 from Malax/dev
Added a warning when the tile set image has not the expected dimensions.
2014-02-21 16:58:06 +00:00
Richard Davey 43bc0e72f1 Merge pull request #460 from nhowell/patch-2
Fix typo of Phaser.World#preUpdate for docs
2014-02-21 15:52:41 +00:00
Richard Davey ad0e53abb9 Merge pull request #459 from nhowell/patch-1
Fix typo of Phaser.TweenManager#pauseAll for docs
2014-02-20 03:44:29 +00:00
Nicholas Howell 6dca66c501 Fix typo of Phaser.World#preUpdate for docs 2014-02-19 22:17:38 -05:00
Nicholas Howell 0fbbb887fc Fix typo of Phaser.TweenManager#pauseAll for docs 2014-02-19 21:48:59 -05:00
Richard Davey f9a63a9d2e Merge pull request #437 from bunnyhero/intersects-return
Return a value from Phaser.Physics.Arcade.intersects().
2014-02-20 02:10:44 +00:00
Richard Davey 92edaf76ef Merge pull request #452 from nhowell/patch-2
Fix typo of Phaser.Line.intersectsPoints for docs
2014-02-20 01:44:08 +00:00
Richard Davey 4c48e88fc1 Merge pull request #453 from nhowell/patch-3
Fix typo of Phaser.Math#fuzzyLessThan for docs
2014-02-20 01:42:47 +00:00
Richard Davey 59a4e80dc1 Merge pull request #454 from nhowell/patch-1
Fix typo of Phaser.Graphics.prototype.destroy for docs
2014-02-20 01:40:09 +00:00
Richard Davey 310eb0a69e Merge pull request #455 from nhowell/patch-4
Fix typo of Phaser.BitmapText.prototype.destroy for docs
2014-02-20 01:39:03 +00:00
Nicholas Howell d5e45c22e9 Fix typo of Phaser.BitmapText.prototype.destroy for docs 2014-02-19 16:16:23 -05:00
Nicholas Howell b9deb43c88 Fix typo of Phaser.Graphics.prototype.destroy for docs
The method was appearing in the wrong file in the documentation
2014-02-19 15:48:38 -05:00
Richard Davey e95ec9fdbc Merge pull request #451 from nhowell/patch-1
Fix typo for Phaser.InputHandler#pointerDragged for docs
2014-02-19 19:05:47 +00:00
Nicholas Howell 936092cba1 Fix typo of Phaser.Math#fuzzyLessThan for docs 2014-02-19 14:05:04 -05:00
Nicholas Howell 0727541e05 Fix typo of Phaser.Line.intersectsPoints for docs 2014-02-19 13:47:54 -05:00
Nicholas Howell 3c6bee8dda Fix typo for Phaser.InputHandler#pointerDragged for docs 2014-02-19 13:21:38 -05:00
Richard Davey 6d418ba9c7 Merge pull request #450 from nhowell/patch-2
Fix typo of Phaser.SinglePad#addCallbacks for docs
2014-02-19 17:00:12 +00:00
Richard Davey 4b3d282f67 Merge pull request #448 from nhowell/patch-1
Fix typo of Phaser.Point#setMagnitude for docs
2014-02-19 16:56:25 +00:00
Nicholas Howell 232d022aaa Fix typo of Phaser.SinglePad#addCallbacks for docs
This typo was causing this method to appear in the wrong page of the docs
2014-02-19 11:18:09 -05:00
Nicholas Howell 26415094b6 Fix typo of Phaser.Point#setMagnitude for docs 2014-02-19 11:08:11 -05:00
Richard Davey e396b56686 Merge pull request #447 from nhowell/patch-3
Fix typos in Phaser.Group#forEachExists for docs
2014-02-19 15:06:13 +00:00
Richard Davey 47f98ac2bc Merge pull request #444 from nhowell/patch-1
Fix typos of method names in Button.js for docs
2014-02-19 15:01:21 +00:00
Nicholas Howell d964ef7d0a Fix typos in Phaser.Group#forEachExists for docs 2014-02-19 09:42:16 -05:00
Nicholas Howell 7db37bf5d5 Fix typos of method names in Button.js for docs 2014-02-19 08:32:05 -05:00
Richard Davey a97357b34e Merge pull request #441 from nhowell/patch-1
Fix typo of Phaser.Key#justReleased for docs
2014-02-19 03:31:19 +00:00
Nicholas Howell e8559fb735 Fix typo of Phaser.Key#justReleased for docs 2014-02-18 21:33:34 -05:00
Richard Davey 58d203619a Merge pull request #438 from georgiee/dev2
Patch for PixiPatch so it renders masks again
2014-02-18 11:23:34 +00:00
Georgios Kaleadis 16dc2c1597 patch for PixiPatch so render masks again 2014-02-18 11:26:10 +01:00
bunnyhero c57071bd98 Return a value from Phaser.Physics.Arcade.intersects. 2014-02-16 21:11:08 -05:00
photonstorm 1f93b62055 Fixes #421 2014-02-14 17:10:29 +00:00
Richard Davey 947985c5b1 Merge pull request #418 from srizzling/patch-1
FIX: Spelling Mistake
2014-02-14 04:40:51 +00:00
Sriram Venkatesh 690bd3e9e2 FIX: Spelling Mistake 2014-02-14 16:21:47 +13:00
Richard Davey 3df4746e8a Merge pull request #417 from clark-stevenson/patch-2
Update phaser.d.ts
2014-02-14 00:15:26 +00:00
clark-stevenson 34e5ee3eb8 Update phaser.d.ts
Fixed #408.
2014-02-14 00:08:11 +00:00
photonstorm 819380d001 Merge branch 'origin/dev' 2014-02-13 23:48:18 +00:00
Richard Davey 26459602aa Merge pull request #409 from clark-stevenson/patch-3
Overhauled Phaser.d.ts
2014-02-13 23:47:24 +00:00
clark-stevenson 79007bc142 Overhauled Phaser.d.ts
Completely reviewed. File in Alphabetical order. Missing classes added, old API's deleted. 

I do expect to be a couple of typos here and there though! So needs tested. I will be using this for my current project.
2014-02-13 13:31:24 +00:00
photonstorm 0641170aab Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee)
Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy)
Added SAT.js to TypeScript definition. Now compiles properly.
Added missing Line.js to the Grunt file.
Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep)
Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64).
Fixed easing tween example case. Issue #379 (thanks wesleywerner)
Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
Removed inContact check from Body.separate.
Fixed Tilemap docs (wrongly pointed to Tileset methods)
2014-02-12 15:33:31 +00:00
photonstorm d9323de752 Docs and Examples update. 2014-02-12 15:26:29 +00:00
photonstorm 1d633a55f0 Merged from dev. 2014-02-12 15:24:59 +00:00
photonstorm 3c631768f2 Explicitly paused Timer continues if you un-focus and focus the browser window (thanks georgiee)
Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception (thanks georgiee)
Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy)
Added SAT.js to TypeScript definition. Now compiles properly.
Added missing Line.js to the Grunt file.
Tilemap#paste diffX and diffY equations changed, fixed issue #393 (thanks brejep)
Added missing return value in Body.hitLeft and hitRight, fixes issue #398 (thanks ram64).
Fixed easing tween example case. Issue #379 (thanks wesleywerner)
Removed SAT.js UMD wrapped, fixes issue #361 (thanks luizbills)
2014-02-12 15:09:44 +00:00
Richard Davey 59ea6746db Merge pull request #393 from brejep/master
Tilemap#paste diffX and diffY equations changed
2014-02-12 14:56:41 +00:00
photonstorm 2a65488eec Added Line.js to the Gruntfile. 2014-02-12 08:25:46 +00:00
Richard Davey cf3b9ae187 Merge pull request #365 from luizbills/dev
browserify/requirejs error with SAT module fixed
2014-02-12 00:57:56 +00:00
photonstorm 10252543f2 Fixed the TypeScript definitions to include the missing SAT classes and other small tweaks. Updated README. 2014-02-10 02:43:57 +00:00
Richard Davey 62da24a7fc Merge pull request #392 from clark-stevenson/patch-1
Update phaser.d.ts
2014-02-09 19:51:28 +00:00
Brett Jephson b0f4ac3bcc Tilemap - reverse diffX and diffY equations in Tilemap#paste. 2014-02-09 17:37:21 +00:00
clark-stevenson e9ab2d30b6 Update phaser.d.ts
Sprite was missing height property
2014-02-09 17:00:07 +00:00
clark-stevenson 27bca6a8c2 Update phaser.d.ts
atlasJSONArray, atlasJSONHash should have optional parameters when it comes to URL/Object? Please disregard this if this is incorrect.
2014-02-09 16:15:10 +00:00
Manuel Giesa 8628c5b2f3 Added a warning when the expected image dimensions of the tile set do not match the actual dimensions. 2014-02-07 17:45:46 +01:00
photonstorm e11cae5373 Added the SAT class to the TypeScript defs file. Also this fixes #369. 2014-02-07 02:50:36 +00:00
Richard Davey c0032e7a58 Merge pull request #368 from Arlefreak/dev
Added description for pad len parameter
2014-02-06 21:19:25 +00:00
photonstorm 9e5e30bb12 Fixed TypeScript defs on lines 1741-1748 (thanks wombatbuddy) 2014-02-06 19:36:33 +00:00
Luiz Bills 03cde81b48 Merge branch 'master' into dev 2014-02-06 11:01:20 -02:00
Luiz Bills b7bb52696f browserify/requirejs error with SAT module fixed 2014-02-06 10:07:23 -02:00
Mario Carballo Zama df2a048594 Added description for pad len parameter 2014-02-06 00:20:40 -06:00
photonstorm 68d5c73fea Explicitly paused Timer continues if you un-focus and focus the browser window.
Added TimerEvent.pendingDelete and checks in Timer.update, so that removing an event in a callback no longer throws an exception.
2014-02-05 22:35:35 +00:00
photonstorm eddce653e9 Preparing for 1.1.5 development. 2014-02-05 21:02:41 +00:00
photonstorm 16fa37081f Merge branch 'origin/dev'
Conflicts:
	README.md
2014-02-05 17:05:26 +00:00
photonstorm fd68a2fe3a Version number updates. 2014-02-05 16:59:54 +00:00
photonstorm e7a9b96d27 Final release 1.1.4 examples finished. 2014-02-05 16:55:02 +00:00
photonstorm 02b75b9e23 Updated doc files. 2014-02-05 16:55:02 +00:00
photonstorm 0896c2fac7 Updating copyright year and README. 2014-02-05 16:54:59 +00:00
photonstorm 8e77e8cedb Lots of TypeScript defs updates for the new Physics / Body classes. 2014-02-05 16:54:58 +00:00
photonstorm 846e9c5061 Removed debug info and tidying up ready for release. 2014-02-05 16:54:58 +00:00
photonstorm 1af86771ba And we have level/ground jitter fixed :) Starstruck is running again properly now too. Time to commit and remove lots of debug data. 2014-02-05 16:54:58 +00:00
photonstorm 84f0f00f49 n-way collision checks and onBeginContact and onEndContact done and working. Also fixed issue in TweenManager.removeAll. 2014-02-05 16:54:58 +00:00
Richard Davey 4502ca1bf6 Merge pull request #359 from qdrj/patch-7
Update phaser.d.ts
2014-02-05 12:33:30 +00:00
Richard Davey 70ad43e71b Merge pull request #357 from qdrj/patch-5
Update phaser.d.ts
2014-02-05 12:33:04 +00:00
qdrj a1ccddcd7e Update phaser.d.ts
Added BitmapText definitions
2014-02-05 01:19:04 -08:00
qdrj 82c39d0866 Update phaser.d.ts
It is a bit confusing that AnimationManager.getAnimation can return animation object or false. Maybe it will better if this method will be returning null instead of false.
2014-02-04 23:24:28 -08:00
Richard Davey 45f9db515a Merge pull request #356 from qdrj/patch-4
Update phaser.d.ts
2014-02-04 03:08:18 -08:00
qdrj 09d4b2bb8b Update phaser.d.ts 2014-02-04 01:32:06 -08:00
photonstorm 8315973c5d Body/Group testing complete. Now focusing on n-way collision. 2014-02-03 04:09:45 +00:00
photonstorm 28f71ed86d Fixed the Sprite / World / Group body issue. So invaders now works again, as do the new examples. 2014-02-03 04:09:45 +00:00
photonstorm 3488880956 Sprite vs. Sprite Group Body Tests. 2014-02-03 04:09:45 +00:00
Richard Davey 33d47cf9e9 Merge pull request #344 from qdrj/patch-1
Update phaser.d.ts
2014-01-31 10:28:21 -08:00
Richard Davey cdb1891420 Merge pull request #350 from qdrj/patch-3
Update phaser.d.ts
2014-01-31 10:28:02 -08:00
qdrj 30af712d6a Update phaser.d.ts
Fix typo StageScaleMode.pageAlignVeritcally
2014-01-31 07:32:17 -08:00
photonstorm 5e182d317b Fixed lots of examples and added the missing Line.js. 2014-01-31 14:12:20 +00:00
Richard Davey 26f2b2a931 Merge pull request #349 from qdrj/patch-2
Update phaser.d.ts
2014-01-31 05:41:22 -08:00
qdrj e5dc16b68d Update phaser.d.ts
Fix incorrect Loader.checkKeyExists declaration
2014-01-31 04:53:19 -08:00
photonstorm 27fc447928 New polygon collision object examples and Body scale fixes. 2014-01-31 10:34:18 +00:00
photonstorm 45b6d5a741 Removed: Debug.renderSpriteTouching, Debug.renderLocalTransformInfo, Debug.renderWorldTransformInfo, Debug.renderSpriteCollision and Debug.dumpLinkedList.
Debug.renderPhysicsBody(body, color) is extremely useful for debugging the new physics bodies. Will draw the outline + points in the color given.
Debug.renderBodyInfo(sprite, x, y, color) will display lots of Sprite body data.
2014-01-31 05:42:20 +00:00
photonstorm 13a86765cb Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.
Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
2014-01-31 04:14:02 +00:00
photonstorm 68b7d22e0d Fixed issue with the camera being slightly out of sync with 'fixedToCamera' sprites. Also fixed 'jitter' issue with camera targets. 2014-01-31 03:32:12 +00:00
photonstorm 6e4e99f436 Added Game Update loop step debugging - has proved utterly invaluable! Resolved camera jitter issues, gravity / downward force on tile/boundary issues and most tilemap collision issues. 2014-01-31 02:06:45 +00:00
photonstorm 651858372c Added Game core loop stepping support. Super-useful for debugging, and helped me track down the issue with jittery physics collision. Double-win! 2014-01-29 17:10:13 +00:00
photonstorm d51a37211c Phaser.Line added to the group of geometry classes, with full point on line/segment and intersection tests (see new examples) 2014-01-29 00:21:28 +00:00
photonstorm 5b85c910cb New lineIntersectLine() function working nicely. 2014-01-28 17:13:07 +00:00
qdrj e5f52e8ae8 Update phaser.d.ts
GameObjectFactory.add.existing should return added object
2014-01-27 23:57:28 -08:00
photonstorm 82cb66f47b Updated intersects code, tilemap collision is running again. Still finding gravity pushing sprites through tiles. 2014-01-28 06:52:56 +00:00
photonstorm 9deb5514a2 ArcadePhysics.setBoundsToWorld implemented. Body.setCircle, setRectangle and setPolygon all working. Tidying up Body class. Need to add tile collision special case handler next. 2014-01-28 05:01:17 +00:00
photonstorm 90c09374af Velocity integration tidied up. Now moving to sync Body with Sprite center point. 2014-01-28 01:29:35 +00:00
photonstorm fbe508ab1b Direct assignment of Body values, allows for sloped ground walking. 2014-01-27 17:08:20 +00:00
photonstorm dbdb2a2026 Adjusted delta timer cap and fixed some typos and more examples. 2014-01-27 17:08:20 +00:00
Richard Davey 4432d37e6e Merge pull request #312 from miguelangelgonzalez/dev
Added missing Typescript definitions
2014-01-27 07:40:45 -08:00
Richard Davey 511858e3f5 Merge pull request #340 from qdrj/patch-2
Update phaser.d.ts
2014-01-27 07:40:25 -08:00
Richard Davey d37ec40d72 Merge pull request #339 from qdrj/patch-1
Update phaser.d.ts
2014-01-27 07:39:54 -08:00
Richard Davey f575967840 Merge pull request #327 from timcooper/dev
Allow fullscreen to work from iframe
2014-01-27 07:39:11 -08:00
Richard Davey 912551a45d Merge pull request #323 from hstolte/patch-1
removed duplicate line in Timer class
2014-01-27 07:37:55 -08:00
photonstorm 4505aa50f6 Integrated SAT. Fixed lots of examples. Fixed documentation. Added new examples and built new phaser.js file for testing. 2014-01-27 06:29:26 +00:00
photonstorm 45518b3ecd Adding checkCollision tests. 2014-01-24 17:30:37 +00:00
qdrj 3fb2eb23cd Update phaser.d.ts
Incorrect TilemapLayer constructor
2014-01-24 01:13:09 -08:00
qdrj 8b06f9cd86 Update phaser.d.ts
Remove duplicated Timer.create signature
2014-01-23 22:50:02 -08:00
photonstorm e3aaec8ac0 Removed Time delta cap, removed drag references from Emitter and tested doing a custom polygon collision. 2014-01-24 03:53:11 +00:00
photonstorm ea9e22f472 SAT implemented and working nicely at long last :) 2014-01-23 21:45:35 +00:00
photonstorm 110ab4e253 More robust gravity handling avoiding 'sticky walls'. Added new platform test with mixture of mass tile collision and physics. 2014-01-23 01:50:43 +00:00
photonstorm 31b68ac94f Removed all references to drag from the Examples and replaced with Friction. 2014-01-22 21:06:16 +00:00
photonstorm 20108e47f3 Working through re-integrating tilemap collision. So far, so good. 2014-01-22 16:16:53 +00:00
photonstorm 1370ba52b5 Fixed Sci-Fly and restored tile collision handling. 2014-01-22 14:49:06 +00:00
photonstorm b2c49ef853 Merging previous changes back in again. 2014-01-22 14:31:18 +00:00
photonstorm f6af6fe0a3 Not fully working, but commit for posterity. Time to rollback if we're ever going to get this released. 2014-01-22 12:31:35 +00:00
photonstorm 7a0e9a478c New Math functions added. 2014-01-22 10:54:49 +00:00
photonstorm 15a002e720 Finally getting there! Body collision almost as good as it can be (without a full-on physics system). Just a few last tweaks to do. 2014-01-21 16:12:50 +00:00
Lucas Monteverde 3236ea6b24 Custom JSON loader
Added a method in the Loader that enable the load of custom json files,
to be used like a the general settings of the game.

loading: game.load.json (key, url);
retrieving data from json file: game.cache.getText(key);
2014-01-21 00:19:42 -02:00
Richard Davey c9d07c7346 Testing out new Body structure 2014-01-20 23:07:56 +00:00
Tim Cooper a81d22a309 Allow fullscreen to work from iframe 2014-01-20 20:58:36 +00:00
photonstorm 128c7143d5 Lots more physics tests and updates.
PLEASE DO NOT upgrade to this release if you need your game working and it uses any of the physics functions, as they're nearly all broken here.
Just pushing up so I can share it with someone.
2014-01-20 20:14:34 +00:00
hstolte 971e17fabe removed duplicate line in Timer class
The method create(...) was defined twice (line 1357 and line 1360). I removed line 1360.
2014-01-18 22:34:28 +01:00
Richard Davey 2532df8793 Merge pull request #317 from gareththegeek/patch-3
Allow Text.style to be any type
2014-01-16 07:28:37 -08:00
Richard Davey c5840f4f6f Merge pull request #316 from gareththegeek/patch-2
Add missing addKey method to Keyboard
2014-01-16 07:28:17 -08:00
Richard Davey 4e7dabb47e Merge pull request #315 from gareththegeek/patch-1
Fix typescript compile error in 0.9.5
2014-01-16 07:27:54 -08:00
gareththegeek 47ee5a2c88 Allow Text.style to be any type
To allow a configuration object to be used rather than a string
2014-01-16 14:48:13 +00:00
gareththegeek ca1f24868a Add missing addKey method to Keyboard 2014-01-16 14:46:12 +00:00
gareththegeek 1f9df6e3f4 Fix typescript compile error in 0.9.5
Explicitly specify type for parameters array
2014-01-16 14:43:28 +00:00
Miguel Angel Gonzalez ac310ab881 Added missing Typescript definitions 2014-01-15 12:15:59 -03:00
photonstorm abdaaa0010 Tidied up the docs and removed some Body vars no longer needed. Now to attempt stacking. 2014-01-15 14:40:25 +00:00
photonstorm 58fb248575 Optimised Body loop, removed sleep properties, implemented minBounceVelocity. Working as expected at last :) 2014-01-15 14:40:25 +00:00
photonstorm 283e38aaae Time to optimise the rebound a little. 2014-01-15 14:40:25 +00:00
photonstorm be6489fbc9 Body bounce + blocking values nearly sorted. 2014-01-15 14:40:24 +00:00
photonstorm 651737fdd0 More physics tweaks. 2014-01-15 14:40:24 +00:00
Richard Davey 88ef644d47 Merge pull request #310 from theadam/dev
Fixed WebGLRenderer updateGraphics bug
2014-01-15 06:23:50 -08:00
Adam Nalisnick 7c66a6b6cc Removed an errant ';' from the end of an 'else if' causing a circle to be drawn each time a graphics object is updated 2014-01-14 20:54:50 -05:00
Richard Davey d8bf13eaaa Merge pull request #309 from jcd-as/dev1
fix sprite vs sprite overlap check
2014-01-14 14:35:06 -08:00
photonstorm bd66be1804 Updated Tilemap classes and further tests. 2014-01-14 22:34:41 +00:00
jcs 01a314018d fix sprite vs sprite overlap check 2014-01-14 13:51:55 -08:00
photonstorm ff7cad102c All of the setCollision methods now have a 'collides' parameter so you can enable or disable collision, not only enable it. Also fixed Loader example. 2014-01-14 11:58:00 +00:00
Richard Davey 8479e456dd Merge pull request #307 from jcd-as/dev
Emitters drag fix.
2014-01-14 01:49:52 -08:00
jcs b4e767161b change Emitter's particleDrag property to particleFriction to match the changes to the physics engine 2014-01-13 20:29:16 -08:00
jcs 6cde583e82 Merge branch 'dev' of https://github.com/photonstorm/phaser into dev 2014-01-13 20:20:06 -08:00
jcs ab02040bea fix Tilemap.putTile 2014-01-13 20:18:08 -08:00
photonstorm 32f5a2fa36 More examples updates. Fixed Starstruck tilemap code, removed un-needed ArcadePhysics methods and rebuilt the js files for testing. 2014-01-14 03:33:03 +00:00
photonstorm 011d2d8e05 The way the collision process callback works has changed significantly and now works as originally intended.
The World level quadtree is no longer created, they are now built and ripped down each time you collide a Group, this helps collision accuracy.
Bodies are no longer added to a world quadtree, so have had all of their quadtree properties removed such as skipQuadtree, quadTreeIndex, etc.
QuadTree.populate - you can pass it a Group and it'll automatically insert all of the children ready for inspection.
Removed ArcadePhysics binding to the QuadTree, so it can now be used independantly of the physics system.
2014-01-14 02:43:09 +00:00
Richard Davey 17af96d46a Merge pull request #306 from jcd-as/dev
fix Tilemap.setCollision
2014-01-13 17:19:25 -08:00
photonstorm bd9898db7e New merged separate function that now uses processCallback the way it was always meant to be used. 2014-01-14 01:18:46 +00:00
jcs befcf74f44 fix Tilemap.setCollision 2014-01-13 16:46:29 -08:00
photonstorm e7c2b6ae9c Fixed nearly all of the tilemap examples to use the new tilemap system. 2014-01-14 00:31:58 +00:00
photonstorm 71f82477ea Tidying up all of the map files, sorting out Tiled paths and updated the tilemap examples for 1.1.4. 2014-01-13 19:45:15 +00:00
photonstorm c6fa2cb7b6 Added the new Timer, TimerEvent and Time methods to the TypeScript definitions files. 2014-01-13 14:18:15 +00:00
photonstorm 35cef4e529 Updated Body file and compiled + minified builds for those wanting to test. 2014-01-09 18:24:12 +00:00
photonstorm 0a0e775ea5 Removed temp. debug vars. 2014-01-09 17:12:24 +00:00
photonstorm 10d105d5ce Acceleration tested and working fine. Proper accurate friction added and working really nicely, so much better than 'drag' used to. Considering removing drag, although will break the API history. 2014-01-09 03:42:58 +00:00
photonstorm 754219a978 Fixed some documentation typos. 2014-01-09 01:23:23 +00:00
Richard Davey 5f9acdca4b Merge pull request #299 from Niondir/dev
Phaser Definitions Update
2014-01-08 17:02:59 -08:00
photonstorm c6c579e6b3 Phaser.Timer is now feature complete and fully documented. You can create Phaser.TimerEvents on a Timer and lots of new examples have been provided. 2014-01-09 00:59:37 +00:00
Tarion c21365703d Phaser Definitions Update
Added "GetCurrentState" to StateManager
2014-01-08 22:57:13 +01:00
photonstorm 35e61172e1 Device.quirksMode is a boolean that informs you if the page is in strict (false) or quirks (true) mode.
Canvas.getOffset now runs a strict/quirks check and uses document.documentElement when calculating scrollTop and scrollLeft to avoid Chrome console warnings.
The Time class now has three new methods: addEvent, repeatEvent and loopEvent. See the new Timer examples to show how to use them.
2014-01-08 11:21:48 +00:00
photonstorm 67e2caafbc Added new Contributors guide. 2014-01-08 11:21:48 +00:00
Richard Davey 038bca11b2 Merge pull request #295 from Niondir/dev
phaser.d.ts corrections
2014-01-07 16:42:52 -08:00
photonstorm bd9b964710 Added a new Full Screen Mobile template example. 2014-01-08 00:34:47 +00:00
niondir 1aabb6b93d World is a Group. Needed to remove stuff again e.g. a "BitmapText" 2014-01-07 19:54:04 +01:00
niondir 77a8dc321f phaser.d.ts corrections 2014-01-07 10:58:00 +01:00
photonstorm 428e331a11 Groups can now be added to other Groups as children via group.add() and group.addAt().
Groups now have an 'alive' property, which can be useful when iterating through child groups with functions like forEachAlive.
2014-01-06 01:39:23 +00:00
photonstorm aa3a86df6e Timer class overhaul. 2014-01-04 02:53:32 +00:00
photonstorm 92033fde7c Added BitDeli badge. 2014-01-03 12:46:13 +00:00
photonstorm 7aa45b5872 Added BitDeli badge, also updating Timer class. 2014-01-03 12:43:58 +00:00
photonstorm c3183dcea9 Angular Physics re-implemented, most tests now working as expected. 2014-01-03 04:50:31 +00:00
Richard Davey f7329e0661 Further physics modifications 2014-01-03 02:24:06 +00:00
photonstorm 5526a7322b Warning: This version has a new ArcadePhysics handler in it. Don't upgrade if you need this for live game code, wait until we go to master. Otherwise, this commit contains lots of new physics demos and a new updateMotion and Body class to try and fix, once and for all, the physics issues with applied forces. 2014-01-02 23:28:22 +00:00
photonstorm 902ffee808 Loader.progressFloat contains the actual non-rounded progress value, where-as Loader.progress contains a rounded value. Use progressFloat if you've > 100 files to load. 2013-12-31 17:35:40 +00:00
photonstorm d1cd1df9a5 Lots of fixes and updates to the Button class, InputHandler for snap offsets, Sound looping and Stage scaling. 2013-12-31 17:03:09 +00:00
photonstorm 86f6ddcbc8 Two new particle examples and a group animation example. Also fixed CocoonJS sound issue and Cache sound locked bug. 2013-12-31 03:37:11 +00:00
photonstorm 3b87ce9fc9 Brand new Gamepad API support fully implemented (thanks to Karl Macklin), with examples to show use. 2013-12-31 01:45:30 +00:00
photonstorm 29d7cc36a0 Merge branch 'gamepadsupport' of https://github.com/karlmacklin/phaser into karlmacklin-gamepadsupport
Conflicts:
	README.md
2013-12-31 00:44:11 +00:00
photonstorm ba74bea4b4 New Group.destroy example and patched the desyrel font xml. 2013-12-30 21:36:50 +00:00
photonstorm ce4cf531d4 Added class constructors, fixed Stripshader, added relative Tween example and updated Tween source. 2013-12-30 16:54:00 +00:00
photonstorm fdbdd81b7b Updated some docs, added the new renderHidden parameter for Canvas and updated the RenderTexture examples as a result. 2013-12-27 00:26:21 +00:00
Richard Davey 2c8077835c Merge pull request #251 from cocoademon/physics_self_collide_fix
Don’t test self-collisions
2013-12-26 15:10:28 -08:00
Richard Davey 10f4bc7507 Merge pull request #278 from inductible-dev/dev
New example suite added, and some TypeScript def tweaks
2013-12-26 15:01:12 -08:00
Richard Davey 923a10ee81 Input no longer sets cursor to default if already set to none 2013-12-26 00:52:01 +00:00
photonstorm 167a498a5e Phaser.Game constructor can now be passed a single object containing game settings + Stage settings, useful for advanced configurations. 2013-12-24 03:18:55 +00:00
inductible.dev 7acf79338c Added examples group: Debug tools 2013-12-23 15:59:58 +00:00
inductible.dev e103d6ae83 Added examples group: Debug tools 2013-12-23 15:59:26 +00:00
inductible.dev 9a968bc5bb TypeScript defs: TileSprite now extends Sprite, and added 'fixedToCamera' property to Sprite definition 2013-12-23 09:48:07 +00:00
photonstorm 0acef49a7c RenderTexture now displays correctly in Canvas games.
Stage.display property added. A direct reference to the root Pixi Stage object (very useful for RenderTexture manipulation)
2013-12-23 04:20:09 +00:00
Richard Davey 5a5d465034 Merge pull request #275 from inductible-dev/dev
added TypeScript definitions for Key and CursorKeys object
2013-12-22 08:30:03 -08:00
inductible.dev 6be31e0f69 added TypeScript definitions for Key and CursorKeys object 2013-12-22 13:34:52 +00:00
photonstorm bf72b4d3b0 Tilemap.createFromObjects can now turn a bunch of Tiled objects into Sprites in one single call, and copies across all properties as well. 2013-12-22 04:27:12 +00:00
photonstorm 63d90a0176 Sprites that are fixedToCamera can now be input dragged regardless of world position. 2013-12-22 03:46:08 +00:00
photonstorm 3cbb820349 You can now load any binary file via the Loader: game.load.binary(key, url, callback) - the optional callback allows for post-load processing before entering the Cache. 2013-12-20 18:27:36 +00:00
photonstorm 352749e803 Collision commands in and working. Updated sci-fly example. Multiple layers rendering. Mixed tile size on one layer rendering, but collision is grid bound. 2013-12-19 05:09:49 +00:00
photonstorm 4c7a4ebf62 Tiled map loader now working much better, rendering, layering properly. 2013-12-19 03:49:28 +00:00
photonstorm 5cf7ed4fdb More TypeScript updates. 2013-12-18 16:56:14 +00:00
photonstorm f991f9cee8 Tweens have a new event: onLoop.
Tweens - Example showing how to use the tween events, onStart, onLoop and onComplete.
Lots of documentation fixes in the Tween class.
Tweens fire an onLoop event if they are set to repeat. onComplete is now only fired for the final repeat (or never if the repeat is infinite)
Tween.onStart is now called when the tween starts AFTER the delay value, if given (thanks stevenbouma)
2013-12-18 13:02:01 +00:00
photonstorm b2c680811b New unified Tiled loader. 2013-12-18 13:02:01 +00:00
Richard Davey 4ada28ba81 Merge pull request #267 from cocoademon/framerate_example
Add an example to show framerate independence in physics calculations
2013-12-17 17:15:33 -08:00
Cameron Foale 55d69e16b6 Add an example to show framerate independence in physics calculations 2013-12-18 11:58:11 +11:00
photonstorm 50eee95c99 Improved TilemapLayer rendering and debug rendering significantly. Cleared out some old assets and added a new map. 2013-12-18 00:44:04 +00:00
photonstorm dd7ae12271 ArcadePhysics.overlap and collide now recognise TileSprites in the collision checks. 2013-12-17 16:48:03 +00:00
Richard Davey a0961f27df Merge pull request #266 from cocoademon/physics_instability_fix
Physics instability fix. I'm merging this in so I can test it against the updates here.
2013-12-17 04:36:38 -08:00
photonstorm 896e9af9f5 TilemapLayers now render tiles correctly, with our without debugging overlay. Collision working well across single and index ranges. 2013-12-17 05:07:00 +00:00
Cameron Foale b8dbb5d125 Take dt into account for gravity calculations 2013-12-17 14:38:44 +11:00
Cameron Foale 388e42c80a Remove invalid multiply by 60 in Phaser.ArcadePhysics.updateMotion 2013-12-17 13:45:15 +11:00
photonstorm 7917eac255 Added Matching Pairs game and updated fixed to camera example. 2013-12-16 15:16:44 +00:00
Richard Davey 39cae4cc09 Sphere snake wip demo 2013-12-14 02:22:14 +00:00
photonstorm 03ae324d26 New user submitted examples 2013-12-13 23:56:39 +00:00
photonstorm a361a18616 Updated IE11 check, forces IE11 to use Canvas renderer even in AUTO mode. 2013-12-13 14:04:14 +00:00
Richard Davey dd9f533528 Merge pull request #134 from gabehollombe/touch_joystick_example
Added touch joystick example
2013-12-11 17:06:10 -08:00
Richard Davey 1b954066a6 Merge pull request #247 from cocoademon/trim_fix
Switch method of using trimmed sprites to support scaling and rotation
2013-12-11 16:52:01 -08:00
photonstorm da5d8c9272 Updated p2.js to latest build. 2013-12-11 03:20:33 +00:00
Richard Davey 215632c0a7 Merge pull request #261 from cocoademon/platform_riding_fix
Fix riding on platforms
2013-12-10 16:05:09 -08:00
Richard Davey 9988a2ffbe Merge pull request #260 from feiss/dev
Tutorials translated to spanish
2013-12-10 16:02:19 -08:00
Cameron Foale 56389fcaf4 Fix riding on platforms 2013-12-11 10:25:57 +11:00
Diego F. Goberna c74bac3a9c Finished translation of tutorial 02 2013-12-10 21:41:33 +01:00
Diego F. Goberna 9f6cfca9cd Title tags fixed 2013-12-10 17:31:54 +01:00
Diego F. Goberna 6805e7264d code comments translated 2013-12-10 17:31:19 +01:00
Diego F. Goberna f7202a3ff1 removed hello world example code
To avoid duplicates. Users may go to the english version (and links in
the tutorial go to the english version)
2013-12-10 17:09:03 +01:00
Diego F. Goberna fc6ae6a60b Finished translation of tutorial 01 2013-12-10 17:05:34 +01:00
Diego F. Goberna 636b1af25c Spanish translation of the tutorials 2013-12-10 16:49:01 +01:00
photonstorm 19759699df More TypeScript definitions fixes (for Easing and Animation data). 2013-12-10 14:34:22 +00:00
photonstorm 669570c701 Tidying up the examples and more Tilemap work. 2013-12-10 12:23:42 +00:00
photonstorm af5847e8e4 Tilemap and game core loop updates. 2013-12-09 16:40:48 +00:00
Richard Davey 2071fc22fc Merge pull request #253 from jcd-as/dev
fix Pixi bug (#425) - fix incorrect width property for multi-line Bitmap...
2013-12-09 02:01:24 -08:00
Richard Davey 55b2dd379a Merge pull request #254 from cocoademon/update_reorder
Split world update into preUpdate and update.
2013-12-09 02:00:49 -08:00
Cameron Foale 3e1207e1a3 Split world update into preUpdate and update.
This allows moving the state.update() call to before world.update(),
meaning results of collisions checked in the state are available to
objects in their own update().
2013-12-09 15:46:02 +11:00
Josh Shepard (jcs) 8ade29d982 fix Pixi bug (#425) - fix incorrect width property for multi-line BitmapText
(Pixi has already merged the fix)
2013-12-08 09:50:21 -08:00
photonstorm 74e0cfb13a Added Tutorial 2. 2013-12-07 02:05:07 +00:00
photonstorm 13a03f3620 TypeScript file updated, now compiles without error in VS and FlashDevelop. 2013-12-06 13:48:40 +00:00
photonstorm 886618c056 Tilemap collision fixed, regardless of rotation, number of overlapping tiles and speed (to a point anyway). Maps also don't crash if they are smaller than the render area. Layers can be positioned successfully anywhere in camera but collision isn't yet offset for this. 2013-12-06 04:34:27 +00:00
photonstorm ca3c71e8f5 Added max overlap clamp. 2013-12-06 02:44:06 +00:00
photonstorm 8e289e6b7c Mostly working, just need to apply a max overlap to avoid tunneling, although a ray would be better. 2013-12-06 02:34:28 +00:00
photonstorm 1f513a333e Fixed an issue where passing null as the Group parent wouldn't set it to game.world as it should have (thanks tito100).
Continued work on the tilemap collision - again, please don't use this version if you need working tilemaps.
2013-12-06 01:07:25 +00:00
photonstorm ea3802a556 Lots of new tilemap code in here. If your game relies on tilemaps then please don't update to this commit unless you want to help debugging! 2013-12-05 18:12:16 +00:00
photonstorm cd314cd03e Group.length now returns the number of children in the Group regardless of their exists/alive state, or 0 if the Group is has no children. 2013-12-05 09:14:49 +00:00
Richard Davey eb3d8241ca Merge pull request #250 from cocoademon/camera_bounds_fix
Switch Camera.setBoundsToWorld to match world.bounds instead of world
2013-12-05 01:11:59 -08:00
Richard Davey fe5fdb164c Merge pull request #245 from oysterCrusher/dev
Introduced a separate stage.fullScreenScaleMode property.
2013-12-05 01:10:02 -08:00
John 2e11801f9f Added a fix for fullscreen scaling in firefox. 2013-12-05 07:15:50 +00:00
Cameron Foale f6712da774 Switch Camera.setBoundsToWorld to match world.bounds instead of world 2013-12-05 16:28:17 +11:00
Cameron Foale b48669dded Don’t test self-collisions 2013-12-05 16:26:03 +11:00
Cameron Foale 8469a9c51e Switch method of using trimmed sprites to support scaling and rotation 2013-12-05 14:52:26 +11:00
John b978a2b73b Introduced a separate stage.fullScreenScaleMode property that is used to decide scaling when fullscreen. 2013-12-05 01:00:36 +00:00
photonstorm c5c754725a * When a Sprite is destroyed any active filters are removed as well.
* Updated Pixi.js so that removing filters now works correctly without breaking the display list.
2013-12-04 22:39:53 +00:00
Richard Davey 8f14483b60 Merge pull request #243 from jcd-as/dev
move 'dirty' flag for Tilemap to a per-layer flag. Fixes #242
2013-12-04 14:38:55 -08:00
Josh Shepard (jcs) 539dcdd18a move 'dirty' flag for Tilemap to a per-layer flag. Fixes #242 2013-12-04 09:42:25 -08:00
photonstorm 666df67453 Tidying up the wip folder and updating pixi. 2013-12-03 20:50:34 +00:00
photonstorm 42c0bed502 Fixed World.scale and Group.scale. 2013-12-03 02:13:57 +00:00
photonstorm 3bfea2101a Start of the Dragonfire game sample 2013-12-01 20:59:52 +00:00
Richard Davey f9ee9bfc0e Merge pull request #239 from jcd-as/dev
move TilemapLayer positioning/rendering to postUpdate to be in line with...
2013-12-01 04:50:39 -08:00
Josh Shepard (jcs) 2b99cb4be4 move TilemapLayer positioning/rendering to postUpdate to be in line with ‘normal’ Sprites.
reverts e91d40b9fc - fix was incorrect & regressed fixedToCamera Sprites’ & TilemapLayer positioning.
Fixes #237
2013-11-30 17:40:24 -08:00
photonstorm 0256117307 Preparing dev branch for 1.1.4 2013-11-29 19:40:28 +00:00
photonstorm 0302e05a83 Small link updates. 2013-11-29 18:48:17 +00:00
photonstorm d9ffd6afd4 Final version of the Getting Started guide. 2013-11-29 18:28:55 +00:00
photonstorm f9b82b66db Tutorial update. 2013-11-29 16:26:59 +00:00
photonstorm efe839978b New Getting Started Tutorial. 2013-11-29 15:16:42 +00:00
photonstorm 00a9897ae2 Updated Filter resolution to a 2f and added Blur and Marble filters. 2013-11-29 12:26:53 +00:00
Richard Davey 378ffc7ade Caustics filter 2013-11-29 10:39:52 +00:00
photonstorm b2fc6c422a Fixed filters for new shader code. 2013-11-28 21:29:16 +00:00
photonstorm f22159e257 Updated documentation. 2013-11-28 15:57:09 +00:00
photonstorm 8da9b67c18 Loader fixed for tilemap data. 2013-11-28 14:22:47 +00:00
photonstorm 780b8a5d6d New filters and demos: LightBeams, Fire and Tunnel. Also Loader can now load script files. 2013-11-28 05:43:35 +00:00
Richard Davey 39025c1c2a Merge pull request #233 from jcd-as/dev
fix for ’jitter’ in scrolling where tilemaps & sprites are one frame off...
2013-11-27 16:57:59 -08:00
Josh Shepard (jcs) e91d40b9fc fix for ’jitter’ in scrolling where tilemaps & sprites are one frame off from each other
Fixes #214
2013-11-27 16:25:20 -08:00
photonstorm a9a46bfbbf Lots of documentation updates and new Loader examples. 2013-11-27 16:33:49 +00:00
photonstorm 4926fac578 New non-conflicting Loading system in place. Creating tests. 2013-11-26 21:10:01 +00:00
photonstorm 2fc5c89c1e Preparing to extend the Loader to handle script loading. 2013-11-26 17:14:21 +00:00
Richard Davey e8646def64 Merge pull request #231 from jcd-as/dev
update the collision hulls in sprite->sprite separations (in addition to...
2013-11-26 03:54:40 -08:00
photonstorm 141337bed9 Heavily optimised PixiShader. 2013-11-26 05:13:56 +00:00
Josh Shepard (jcs) f4688241d2 update the collision hulls in sprite->sprite separations (in addition to sprite->tile separations) 2013-11-25 20:58:39 -08:00
photonstorm 86584a636c Added new Phaser.HEADLESS render mode (doesn't output anything). 2013-11-25 14:53:30 +00:00
photonstorm 06a17b4b26 Fixed an issue in Text. Fixed the background color issue with Canvas games. Updated the Examples viewer so the side-by-side focuses the iframe now. Added new "Extend Group" example. 2013-11-25 13:12:03 +00:00
photonstorm 299115ca5d The entire Phaser library has been updated to match the new JSHint configuration. 2013-11-25 04:40:04 +00:00
photonstorm 13a2cc2feb Updating all files to adhere to the JSHint settings and fixing lots of documentation errors on the way. 2013-11-25 03:13:04 +00:00
Richard Davey 373b97648d Documentation updates 2013-11-24 23:52:31 +00:00
photonstorm a876fdd2b6 README update, Loader audio path fix and Tween.isRunning fix. 2013-11-24 13:16:55 +00:00
Richard Davey cbd9b77327 Merge pull request #218 from TheJare/dev
Fix normalizeAngle and wrapAngle (again?)
2013-11-24 05:09:06 -08:00
photonstorm d30e2974c4 Updated JSHint configuration, README and started working through source files against JSHint. 2013-11-24 12:51:20 +00:00
Richard Davey 16ae7f3cb7 Merge pull request #225 from kevinthompson/kt/jshint
Add JSHint configuration.
2013-11-24 04:29:33 -08:00
photonstorm 155c863d69 New Timer class and scale event updates. 2013-11-24 11:04:58 +00:00
Kevin Thompson 82f019d4d2 Add JSHint configuration. 2013-11-23 09:08:23 -08:00
TheJare 8015194daa Fix normalizeAngle and wrapAngle (again?) 2013-11-23 02:58:02 +01:00
photonstorm 7d7aa795e7 New Fire filter. 2013-11-21 12:34:41 +00:00
photonstorm b286093093 Opps forgot to fix a rogue filter which caused the lib to crash. 2013-11-21 05:31:23 +00:00
photonstorm 496639ff25 Added Phaser.Filter and started moving the shaders over into their own filter classes, so they won't all get bundled in unless needed. 2013-11-21 05:00:07 +00:00
Richard Davey e32c127a97 Merge pull request #212 from TheJare/dev
Fixes to Math and Loader
2013-11-20 04:51:25 -08:00
Richard Davey ca297318f0 Merge pull request #211 from cocoademon/fix_skip_children
Fix a silly mistake in skip preupdate/update for PIXI objects
2013-11-20 04:50:34 -08:00
photonstorm 577e3f8506 Heroku shader conversion :) 2013-11-20 06:31:49 +00:00
photonstorm 93fcb7acbf Loads more shaders and some fixes and enhancements to PixiShader 2013-11-20 04:04:48 +00:00
photonstorm e620c99479 ShaderToy convertor up and working, lots of shaders being turned into Pixi filters :) 2013-11-20 02:28:28 +00:00
TheJare f115a2dbf8 Remove references to GameMath, it's just Math now
Throw exceptions if wrong format given to tilemap or textureatlas. Previously, old onload remained active and error happened in the wrong (and hard to diagnose) place.
2013-11-20 00:12:37 +01:00
Cameron Foale 9b6bfa5f37 Fix a silly mistake in skip preupdate/update for PIXI objects 2013-11-20 09:45:27 +11:00
Richard Davey 40e1b4b9aa Merge pull request #210 from cocoademon/skip_pixi_updates
Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist
2013-11-19 04:20:17 -08:00
photonstorm 6ed6820429 Grid Gunner: Book demo game 2013-11-19 05:34:08 +00:00
Cameron Foale 7ef5ab8c98 Skip preupdate/update for PIXI hierarchies in which an ancestor doesn't exist 2013-11-19 16:29:02 +11:00
Richard Davey e43571980d Book files 2013-11-19 00:25:55 +00:00
photonstorm b63bd14172 ScaleMode fix, BitmapData change and Device updates. 2013-11-18 20:27:40 +00:00
photonstorm a5f2d65d23 Fixing a few more Pixi issues. 2013-11-17 12:31:57 +00:00
photonstorm 7ad4164e3a Expanding BitmapData 2013-11-17 04:33:16 +00:00
Richard Davey ba6863bdf5 bmd tweaks 2013-11-17 00:55:28 +00:00
photonstorm 38bd00b4ed ArcadePhysics.separateTile wasn't returning the value, so the custom process callback wasn't getting called (thanks flameiguana) 2013-11-16 13:47:12 +00:00
Richard Davey 3249aa2673 Merge pull request #204 from gltovar/dev
Update typescript definition file
2013-11-16 05:45:42 -08:00
Louis Tovar 4d80d6c9b2 Merge remote-tracking branch 'photonstorm_phaser/dev' into dev 2013-11-15 14:21:00 -08:00
Louis Tovar 04ebae7a9f a basic state project that leads to breakout 2013-11-15 13:50:41 -08:00
Louis Tovar 0dab85c853 latest version of typescript definitions, manual changes to get it to code hint properly. 2013-11-15 13:50:16 -08:00
Louis Tovar 266b62caff adding the game state 2013-11-15 13:49:22 -08:00
photonstorm 83cacb93a0 More updates to BitmapData. 2013-11-15 20:40:55 +00:00
Richard Davey 8d48576fe2 Updates 2013-11-14 16:24:27 +00:00
Richard Davey ebe441666c BitmapData object added 2013-11-13 20:57:09 +00:00
Louis Tovar 254bf67e16 Working on creating a test project in typescript using the Template JS and Breakout game. More to come 2013-11-13 01:26:15 -08:00
Louis Tovar f71b8d4df1 Manual fixes for TypeScript definitions file. Not Complete, more to come 2013-11-13 01:24:26 -08:00
Richard Davey 6a24d6116b Lots of renderTexture updates and examples added 2013-11-13 06:49:24 +00:00
Richard Davey e4faa34908 Merge pull request #188 from Izzimach/izz
Switched Tilemap to use user-specified layer.
2013-11-12 16:33:43 -08:00
Richard Davey 71b08cafbd Merge pull request #184 from crazysam/dev
Implementing PluginManager.remove, added PluginManager.removeAll
2013-11-12 16:32:43 -08:00
Richard Davey 9dc7c73135 Merge pull request #181 from jcd-as/dev
Added scrollFactorX/scrollFactorY to TilemapLayers
2013-11-12 16:31:51 -08:00
Richard Davey e271f69527 Merge pull request #170 from beeglebug/selectors
Phaser.Game parent can now be a HTMLElement
2013-11-12 16:26:42 -08:00
photonstorm 46cf024a35 filter test updates 2013-11-09 02:16:52 +00:00
Izzimach 1d20c07ed9 Merge remote-tracking branch 'origin/dev' into izz 2013-11-08 12:04:24 -07:00
Izzimach 18a07f7a88 Switched Tilemap to use user-specified layer.
Tilemap was using the current layer even if a layer was specified as a
parameter in getTile/setTile. Changed it to use the user layer if one is
specified.
2013-11-08 11:40:07 -07:00
Samuel Batista 13fdca9cf5 Merge branch 'dev' of https://github.com/crazysam/phaser into dev 2013-11-08 01:13:58 -05:00
Samuel Batista 084c4239e5 Implementing PluginManager.remove function, added PluginManager.removeAll function. 2013-11-08 01:11:36 -05:00
Josh Shepard b35da01cfc Added scrollFactorX/scrollFactorY to TilemapLayers - controls rate of movement of layers as a factor of camera position 2013-11-07 10:44:04 -08:00
photonstorm 3f99b691c9 Added in a Group.sort demo, also updated the documentation and build files. 2013-11-07 06:10:15 +00:00
photonstorm 42cd8bd812 Added Group.sort, can sort the Group based on any given numeric property (x, y, health), finally you can do depth-sorting :) 2013-11-07 04:31:37 +00:00
photonstorm 789f0bb0a1 Fixing up Group.sort 2013-11-06 17:43:01 +00:00
photonstorm dfb22f1044 Tracked down an evil bug in Group.swap that caused the linked list to get corrupted in an upward (B to A) neighbour swap. 2013-11-06 16:46:21 +00:00
photonstorm 8b793cd8d7 Updated to latest version of Pixi.js. Lovely new WebGL filters now working happily :) 2013-11-06 04:51:23 +00:00
photonstorm 94d9fa6e77 Tidying up some docs. 2013-11-05 21:44:39 +00:00
Richard Davey de34a13545 Merge pull request #176 from rjimenezda/dev
Polygon class & drawPolygon method
2013-11-05 13:20:35 -08:00
Román Jiménez 35dd98c72f Added some docstring to the Polygon class 2013-11-05 20:31:33 +01:00
Román Jiménez 06e33bc8e4 Polygon & drawPolygon method 2013-11-05 20:25:06 +01:00
photonstorm 1eca16a948 ArcadePhysics.updateMotion applies the dt to the velocity calculations as well as position now (thanks jcs) 2013-11-05 16:14:24 +00:00
Samuel Batista 32bff9e419 Merge pull request #1 from photonstorm/dev
Dev
2013-11-04 16:07:59 -08:00
beeglebug 00664f9e99 Phaser.Game parent can now be a HTMLElement 2013-11-04 21:29:32 +00:00
photonstorm fa8533f5d1 Added Tetris sprites 2013-11-04 20:45:51 +00:00
photonstorm 2e576fa9a7 Input Handler updates, orientation screen and World visibility 2013-11-04 20:44:32 +00:00
photonstorm 19ddad8095 Mouse handler updates. 2013-11-04 20:44:32 +00:00
Richard Davey 9022a2f9d3 Merge pull request #160 from cocoademon/camera_shake
Add a postUpdate function to plugins
2013-11-03 18:58:04 -08:00
Richard Davey 0e84b7ccc9 Merge pull request #162 from beeglebug/button
Button now goes back to over state when setFrames used in action
2013-11-03 18:39:54 -08:00
Richard Davey a5c8b2509c Merge pull request #167 from wKLV/dev
Mouse now knows what button is clicked
2013-11-03 18:21:53 -08:00
Richard Davey c1d60d7e19 getAnimation and RAF callback ID checks added 2013-11-04 00:04:19 +00:00
wKLV 8678373754 fix typo 2013-11-04 00:18:59 +01:00
wKLV e8bac6c8c7 Check type uses the static values 2013-11-04 00:16:36 +01:00
KLV 4593a42a5b Mouse property to say what button is being clicked
It follows the convention that already was in the
file 0 for left, 1 for middle and 2 for right.
It also changes to -1 when mouseUp.
2013-11-03 23:43:47 +01:00
beeglebug 3227918c57 fix #154 Button now goes back to over state when setFrames used in action 2013-11-02 11:24:00 +00:00
Cameron Foale a96ced0d82 Add a postUpdate function to plugins, which is called after World.postUpdate 2013-11-02 17:04:32 +11:00
photonstorm cc42a71c66 Preparing 1.1.3 dev branch 2013-11-01 19:05:47 +00:00
photonstorm 3e9777e6f4 Updated docs for 1.1.2 release. 2013-11-01 18:16:52 +00:00
Richard Davey eb95ce231b Merge pull request #159 from alvinsight/dev
Tidied up space invaders' code base
2013-11-01 11:13:55 -07:00
alvinsight d0889fcc17 Tidied up the code base 2013-11-01 18:04:54 +00:00
photonstorm 160a321a36 Updated invaders demo. 2013-11-01 17:37:32 +00:00
photonstorm 685054eac5 Group.callAll now supports nested functions and a context, making it really powerful! 2013-11-01 17:29:57 +00:00
Richard Davey 19ac33f970 Merge pull request #158 from alvinsight/dev
Invaders game improved
2013-11-01 10:30:00 -07:00
alvinsight 56c7f1f275 Invaders game improved 2013-11-01 17:02:06 +00:00
Richard Davey 51a42c2f12 Merge pull request #155 from alvinsight/dev
Tilemaps examples updated
2013-11-01 07:50:54 -07:00
Webeled e3f76ce481 Tilemaps examples updated 2013-11-01 12:25:14 +00:00
Richard Davey bd752785b9 Merge pull request #150 from beeglebug/master
added getMagnitude, setMagnitude, normalize and isZero methods to Point
2013-11-01 04:37:54 -07:00
photonstorm 787abc1e02 Updated debug header and added more info to the project template. 2013-11-01 04:58:08 +00:00
photonstorm 581d637663 Added Group.cursor. This points to the first item added to a Group. You can move the cursor with Group.next() and Group.previous(). 2013-11-01 02:50:00 +00:00
photonstorm 3c164b466c * Updated: event.preventDefault() has been added to all Mouse event handlers.
* Updated: Sprite.deltaX/Y removed due to non-use. prevX/Y values moved to Sprite._cache.prevX/Y.
* Updated: Due to missing extends parameter the Sprite prototype was picking up functions from classes it never meant to (Button, TilemapLayer), now fully isolated.
2013-11-01 02:07:21 +00:00
photonstorm 01eab3aeb1 Fixed issue 141 - If a Sprite is dragged and you release the Pointer while not over the Sprite, it will think it's still over it (thanks Paratron) 2013-10-31 16:27:10 +00:00
photonstorm 6f93a2ec94 Multiple Anims update, Tilemap fixes and some new examples. 2013-10-31 15:45:19 +00:00
Stuart Lee 903c2e73fa added getMagnitude, setMagnitude, normalize and isZero methods to Point 2013-10-31 14:11:03 +00:00
photonstorm 712858cf75 More work on the Invaders game. 2013-10-31 05:31:54 +00:00
photonstorm ddf15979d0 Fixing up Invaders and Star Struck. Also removing lots of un-used css jsdoc themes. 2013-10-31 01:45:16 +00:00
Richard Davey ebf4456e4e Merge pull request #147 from beeglebug/scope
state callbacks now receive game object as argument
2013-10-30 18:44:35 -07:00
Stuart Lee 01f64c6694 state callbacks now receive game object as argument 2013-10-30 16:09:06 +00:00
Richard Davey 0a77690f4f Merge pull request #144 from beeglebug/dev
hexToRGB now accepts short hex codes (#EEE)
2013-10-30 07:16:41 -07:00
Stuart Lee 9030fbf352 hexToRGB now accepts short hex codes (#EEE) 2013-10-30 13:34:46 +00:00
photonstorm 24c809dd5f Final body / physics / bounds fixes. Also updated various examples, optimised Sprite core loop and enhanced the Invaders example. 2013-10-30 03:46:52 +00:00
photonstorm 3de62907a0 Nearly fixed the tilemap / body issue. More tests needed but then can push to master. 2013-10-29 04:07:26 +00:00
photonstorm 7ceb11ae49 New: You'll now find a complete Basic project Template in the resources/Project Templates folder. Will add more complex ones soon. 2013-10-28 23:29:34 +00:00
Gabe Hollombe 62656783f0 add gamecontroller.js to view_lite.html for the side_view layout 2013-10-28 18:56:48 +08:00
Richard Davey 2b40d2f507 Merge pull request #139 from beeglebug/master
Added init method to plugins, to be called as they are added to the PluginManager
2013-10-28 03:28:13 -07:00
photonstorm a814cc26cc * Fixed issue 135 - Added typeof checks into most ArcadePhysics functions to avoid errors with zero values.
* Fixed issue 136 - distanceTo using worldX/Y instead of x/y.
2013-10-28 10:17:36 +00:00
photonstorm ea651113df Preparing for 1.1.2 release. 2013-10-28 00:16:20 +00:00
beeglebug f00c52598b added init method to plugins
this will allow potentially destructive code to run outside of the
constructor, and only if it has been added to the PluginManager
2013-10-27 22:30:01 +00:00
Gabe Hollombe 7a9508d01d Added touch joystick example
Using Clay.io's HTML5 Virtual Game Controller
2013-10-27 15:59:05 +08:00
photonstorm 9261160571 1.1.1 release with fix for Phaser.AUTO and a new text example. 2013-10-26 19:14:13 +01:00
photonstorm 2787ed188e Preparing for 1.1.2 release 2013-10-26 12:17:22 +01:00
photonstorm b6efdff286 Adding the key capture to addCursors. 2013-10-25 19:13:00 +01:00
photonstorm 6994e4be5e Merge branch 'dev' 2013-10-25 18:50:14 +01:00
photonstorm bd5bca14fe Small url update. 2013-10-25 18:38:01 +01:00
photonstorm 34736fbde5 Final 1.1 release. Here goes nothing :) 2013-10-25 18:35:49 +01:00
Richard Davey 155c36b0fd Merge pull request #126 from alvinsight/dev
Second commit, all the basic examples added, and wip files moved
2013-10-25 10:13:55 -07:00
Webeled 8dfe5aee1c Second commit, all the basic examples added, and wip files moved 2013-10-25 18:10:03 +01:00
Richard Davey 3f9c07d783 Merge pull request #125 from alvinsight/dev
Basic examples created
2013-10-25 10:07:17 -07:00
Webeled f63e8d7d06 Basic examples created 2013-10-25 18:00:25 +01:00
photonstorm 65d2bf557b Updated docs and more tidying up. 2013-10-25 17:30:37 +01:00
photonstorm 9f9e6a2a57 Lots of doc updates! 2013-10-25 16:54:40 +01:00
Richard Davey 0463bb4333 Merge pull request #124 from alvinsight/dev
A lot of documentation updates
2013-10-25 07:51:38 -07:00
Webeled 12148b3159 More improvements on GameObjectFactory 2013-10-25 15:42:48 +01:00
Webeled ce04ade458 Lots of JSDocs updates in the gameobjects folder 2013-10-25 15:22:45 +01:00
photonstorm a08436abc3 Final Sprite documentation added. 2013-10-25 15:02:21 +01:00
Webeled 35517d94ad Just to test if smartGit works again 2013-10-25 14:31:25 +01:00
photonstorm 2659ed7a4a Updated readme. 2013-10-25 06:01:36 +01:00
Richard Davey ba57f0ae0d Merge pull request #123 from TomTom1229/dev
Manually created a more accurate TypeScript definition file
2013-10-24 21:50:53 -07:00
photonstorm d8a2b9d2af Removed console.log 2013-10-25 05:43:10 +01:00
photonstorm 2921a6de2e Pixel Perfect click detection now works even if the Sprite is part of a texture atlas. 2013-10-25 05:40:46 +01:00
Tomas Morris d30f709208 Manually created a more accurate TypeScript definition file 2013-10-24 21:24:35 -06:00
photonstorm 1294b3a2b9 Input over now works regardless of rotation, anchor or scale. 2013-10-25 03:57:08 +01:00
photonstorm 427819c655 Sprite bounds finally correct, regardless of rotation, parenting, scale or anchor. 2013-10-25 03:50:15 +01:00
photonstorm 1469663ea5 Button fixes and Input coordinate fixes. 2013-10-25 02:19:16 +01:00
photonstorm 1f28d328a7 Commit before refactoring Sprite guts. 2013-10-24 21:21:00 +01:00
Richard Davey 03054c1949 Merge pull request #121 from ooflorent/examples-order
Fix order of examples
2013-10-24 06:03:46 -07:00
Florent Cailhol 708a144c7a Sort example directories 2013-10-24 14:12:54 +02:00
Florent Cailhol f6b50c4520 Fix order of examples 2013-10-24 14:08:57 +02:00
Richard Davey f522cda325 Merge pull request #120 from ooflorent/verbose-examples
Remove path.relative() which produce unexpected results on Windows
2013-10-24 04:51:35 -07:00
Florent Cailhol ab6dbfb49e Remove path.relative() which produce unexpected results on Windows 2013-10-24 13:32:04 +02:00
Richard Davey f784a395ce Merge pull request #119 from ooflorent/verbose-examples
Add verbose output to examples task
2013-10-24 03:57:09 -07:00
Florent Cailhol 9ed930c4cf Add verbose output to examples task
Verbose output:
https://gist.github.com/ooflorent/7134728
2013-10-24 12:25:59 +02:00
photonstorm a6fac64248 Loads of issues reported on Github resolved (sprite crop, music resume, etc). 2013-10-24 04:27:28 +01:00
Richard Davey e4621aafdd Merge pull request #115 from ooflorent/grunt-build
Build phaser using Grunt
2013-10-23 09:11:51 -07:00
photonstorm 7e5f38d022 Phaser.Time physicsElapsed delta timer clamp added. Stops rogue iOS / slow mobile timer errors causing crazy high deltas. 2013-10-23 17:11:06 +01:00
Florent Cailhol dfee9f9b2f Add new Grunt build 2013-10-23 16:58:48 +02:00
Florent Cailhol 7b052c302f Remove old gruntfile 2013-10-23 16:50:28 +02:00
photonstorm 94c7c57e1c Fixed WebGL detection and code colour on Firefox. 2013-10-23 15:13:21 +01:00
photonstorm ffd5ddc534 Tidying up the repo and adding in new documentation. 2013-10-23 14:00:29 +01:00
photonstorm 4a51ac4671 Updated README and sorting out folder case issue. 2013-10-23 13:30:23 +01:00
photonstorm f1f42e4d41 New Examples area finished, README updated. Getting closer to 1.1 release. 2013-10-23 04:15:44 +01:00
photonstorm cab3b53cf0 SideView example viewer finished. 2013-10-23 02:14:51 +01:00
photonstorm e5c3ca27c5 Making dependancies local for offline access to examples. 2013-10-22 21:29:58 +01:00
Richard Davey 84b837f56c View 2013-10-22 16:38:40 +01:00
photonstorm 77fd15bf3c Preparing new static examples viewer. 2013-10-22 14:59:43 +01:00
photonstorm 07724e5001 Revamping the examples area. 2013-10-22 03:58:20 +01:00
Richard Davey 82df8c9f54 Merge pull request #108 from alvinsight/dev
All the names now fit
2013-10-18 08:36:13 -07:00
Webeled 97423a9d8d All the names now fit 2013-10-18 16:27:55 +01:00
photonstorm 8ed783802e New examples page 2013-10-18 15:12:32 +01:00
photonstorm dabda516c2 Compiled build. 2013-10-17 22:56:20 +01:00
photonstorm 7e8b79adf4 Tilemap painting example and other smaller updates. 2013-10-17 21:10:00 +01:00
photonstorm 275fa4641e Added Text.destroy and BitmapText.destroy. 2013-10-17 15:40:44 +01:00
photonstorm 4b2ac6c6c6 More tilemap examples 2013-10-16 21:25:51 +01:00
photonstorm 9c1fdb371c Nearly finished Tilemap integration into the core. 2013-10-16 06:33:39 +01:00
photonstorm 31018b9295 Star Struck game back and working again, plus finished the level design. 2013-10-16 03:37:15 +01:00
photonstorm a97f271de7 Fixed Animation index 0 issue and hooked TilemapLayer to camera. 2013-10-16 02:09:12 +01:00
photonstorm fd5eeb9088 Fixed Rectangle intersection issue and tilemap collision is working again. Win! 2013-10-15 15:24:07 +01:00
photonstorm f3ea68aad3 Extracting the correct area from a layer, debug displaying it and preparing for collision. 2013-10-15 05:41:42 +01:00
photonstorm dd695e066f More tilemap tweaks. 2013-10-14 19:37:52 +01:00
Richard Davey 6147e07a5f Merge pull request #104 from alvinsight/dev
Loads of new examples, some more bug fixes, all of them work beautifully
2013-10-14 11:37:18 -07:00
Webeled 969fa46484 Loads of new examples, some more bug fixes, all of them work beautifully 2013-10-14 19:32:07 +01:00
Richard Davey faf432bdb0 Merge pull request #102 from alvinsight/dev
Well, almost every example works with 1.0.7 except multiple anims, plus some funky tweens examples, and renamed a lot of files
2013-10-14 05:47:38 -07:00
Webeled 44613f7140 Should resolve the conflict 2013-10-14 13:40:02 +01:00
photonstorm 78dbb1aa59 Tidying up the repo. 2013-10-14 13:20:52 +01:00
photonstorm c6bf67c392 Group.alpha exposed and instance returns added to Loader functions. 2013-10-13 20:28:06 +01:00
photonstorm e98aa205ea Sprite.destroy is back in business. 2013-10-13 01:29:57 +01:00
Webeled 786aa2900e Final commit of the day 2013-10-11 22:49:51 +01:00
Webeled eb98998046 Testing 2013-10-11 22:29:50 +01:00
Webeled 3acdad92cb First commi using the new software 2013-10-11 22:26:27 +01:00
photonstorm 574f4f351b Github Issue #101 fixed. Plus more Tilemap updates. 2013-10-11 20:02:12 +01:00
photonstorm 0201baef11 And Tilemaps are rendering again - and much better than ever before :) Just one final optimisation pass to do and then it's on to collision. 2013-10-11 18:18:27 +01:00
photonstorm cf414394c3 Tileset working, map coming next. 2013-10-11 06:30:28 +01:00
photonstorm b868c2cb1b Started revamp of the Tilemap system. Also removed old 'Advanced Physics' and dropped in p2.js which is what I hope we'll eventually use. 2013-10-11 04:42:11 +01:00
photonstorm a7230aa769 Sprite.loadTexture added. 2013-10-10 09:03:38 +01:00
photonstorm f10f9324ad Animation.killOnComplete added and fixed a few issues in the Tanks game. 2013-10-09 13:36:57 +01:00
photonstorm 29acf7fb4b Enemy tanks, now firing. 2013-10-09 07:11:36 +01:00
photonstorm ca9321ef42 Updated physics body to use localTransform. Updated tanks demo. 2013-10-09 05:13:38 +01:00
photonstorm 83a00862be Lots of new examples and updates. 2013-10-09 04:31:08 +01:00
Richard Davey 1c577d3674 Fixed RandomDataGenerator.sow 2013-10-08 22:55:27 +01:00
photonstorm f5584bdfe5 Lots of fixes and updates to ArcadePhysics and Group, plus more examples. 2013-10-08 21:09:46 +01:00
photonstorm ebc4e5dc3d New examples HTML page added. 2013-10-08 12:52:20 +01:00
photonstorm fa692653e3 Final commit before rebuilding the Tilemap system. 2013-10-08 10:52:15 +01:00
photonstorm c307f79102 Added Sprite.fixedToCamera, fixed Angular Velocity and Acceleration, fixed jittery Camera, added skipQuadTree flag and created lots more examples. 2013-10-08 00:58:20 +01:00
photonstorm 1bc6ac25fa Preparing to merge new examples. 2013-10-07 22:15:28 +01:00
Richard Davey d4149a8f9a Setting up for this weeks work. 2013-10-07 22:15:28 +01:00
Richard Davey 9ed2dc8e89 Merge pull request #93 from alvinsight/dev
Changed all the examples I could so most of them now work with 1.0.7, and removed the self executing anonymous functions
2013-10-07 14:15:00 -07:00
Webeled 1a522ea786 Removed the self-executing functions 2013-10-07 21:32:34 +01:00
Webeled 77b553ac2a Test 2013-10-07 20:56:44 +01:00
Richard Davey 664c512a99 Fixed small typo. 2013-10-06 16:27:39 +01:00
Richard Davey 47e1b1b54b Sprite optimisations. 2013-10-04 19:00:55 +01:00
Richard Davey 455b18b7ec Sprite optimisations :) 2013-10-04 18:09:56 +01:00
Richard Davey c00bf96603 World and Camera updates nearly complete. 2013-10-04 16:51:24 +01:00
Richard Davey e8bed83ac3 Making some major changes to Camera and World. 2013-10-04 14:41:15 +01:00
Richard Davey 54f073e5cb Testing some new Camera tricks. 2013-10-03 23:20:24 +01:00
Richard Davey c8760b4341 Docs update. 2013-10-03 04:17:44 +01:00
Richard Davey 96da57cac0 Fixed up the namespace in the documentation and finished off all sections other than Game Objects and Physics (yuck). 2013-10-03 02:38:35 +01:00
Richard Davey f832bacfd6 More Docs! 2013-10-03 01:21:08 +01:00
Richard Davey e85643abf4 Yet more documentation done. 2013-10-02 20:18:24 +01:00
Richard Davey 868ae81bab Input, Loader and Math docs tidied up. 2013-10-02 15:05:55 +01:00
Richard Davey 1a2dc05609 Input and keyboard docs. 2013-10-02 13:18:58 +01:00
Richard Davey 852e82d0ca More docs. 2013-10-02 12:11:22 +01:00
Richard Davey 2a01fbb0e8 Merge pull request #87 from STuFF/patch-1
fix typo
2013-10-02 03:23:53 -07:00
Richard Davey 6ce6330f50 More docs. 2013-10-02 11:22:48 +01:00
Nicolas Challeil d2bd2e1600 fix typo
small contribution is small :)
2013-10-02 09:46:42 +02:00
Richard Davey 82325ecc8a Finished Group documentation. 2013-10-02 01:51:30 +01:00
Richard Davey e5b1faace6 Preparing more documentation. 2013-10-02 01:16:40 +01:00
Richard Davey 7c7cd8b01d More docs and quick patch to stop the body.allowRotation messing things up. 2013-10-01 16:56:47 +01:00
Richard Davey ca113b85aa More docs coming on. 2013-10-01 16:39:39 +01:00
Richard Davey a38ad2d1a9 Merge pull request #85 from onedayitwillmake/dev
Fixed accidentally overwroting remove function with a prepend function
2013-10-01 08:16:16 -07:00
Richard Davey 9b4b267e7a Working through building the docs. 2013-10-01 16:15:45 +01:00
Mario Gonzalez f593afd164 Fixed accidentally overwroting remove function with a prepend function 2013-10-01 10:08:09 -04:00
Richard Davey 0a98bb67d8 jsdoc blocks added to every file and tidied up. 2013-10-01 15:05:30 +01:00
Richard Davey 305b12d76b Adding docs. 2013-10-01 15:01:46 +01:00
Richard Davey fa15f8015d Fixed bug in LinkedList#remove that could cause first to point to a dead node 2013-10-01 11:28:57 +01:00
Richard Davey 3740ea05ee Merge pull request #84 from onedayitwillmake/dev
Fixed bug in LinkedList#remove that could cause first to point to a dead node
2013-10-01 03:01:38 -07:00
Mario Gonzalez fa8ad51c79 Fixed bug in LinkedList#remove that could cause first/tail to be have pointers to dead node 2013-09-30 22:06:48 -04:00
Richard Davey 480d90b009 * Removed the callbackContext parameter from Group.callAll because it's no longer needed.
* Updated Group.forEach, forEachAlive and forEachDead so you can now pass as many parameters as you want, which will all be given to the callback after the child.
* Updated build script so it can be run from the command-line and includes UMD wrappers (thanks iaincarsberg)
2013-10-01 02:19:08 +01:00
Richard Davey 8668b82ef6 * Fixed issue causing Keyboard.justPressed to always fire (thanks stemkoski)
* Added Keyboard.addKey() which creates a new Phaser.Key object that can be polled for updates, pressed states, etc. See the 2 new examples showing use.
2013-10-01 01:18:29 +01:00
Richard Davey fa1ed04aa8 Build 2013-09-30 19:54:43 +01:00
Richard Davey 83fc38344c Merge pull request #80 from webeled/dev
Tons of new examples
2013-09-30 11:53:55 -07:00
Webeled 5afce4bf8e Revert "Manual update"
This reverts commit 4b177e0a9b.
2013-09-30 19:18:33 +01:00
Webeled 933edb203f Final Commit of the day,
Final commit, the wip/examples folder can be removed,
2013-09-30 19:13:01 +01:00
Webeled bdc8edea9d Lots of new examples :)
Lots of new examples, the wip/examples folder can be destoryed I think
2013-09-30 17:31:03 +01:00
Richard Davey 16b1913de1 * Fixed issue in Sound.play where if you gave a missing marker it would play the whole sound sprite instead.
* Button.setFrames will set the current frame based on the button state immediately.
* InputHandler now creates the _pointerData array on creation and populates with one empty set of values, so pointerOver etc all work before a start call.
* Added Canvas.setUserSelect() to disable touchCallouts and user selections within the canvas.
* When the game boots it will now by default disable user-select and touch action events on the game canvas.
* Loaded.setPreloadSprite now rounds the width/height values and starts from 1. This fixes canvas draw errors in IE9/10 and Firefox.
2013-09-30 17:12:22 +01:00
Webeled 4b177e0a9b Manual update 2013-09-30 13:26:56 +01:00
Richard Davey 8d17e1f963 Sound duration fixes. 2013-09-30 12:17:21 +01:00
Richard Davey e846f3cbac Fix for incorrect new particle positioning (issue #73) 2013-09-30 12:17:21 +01:00
Richard Davey e3384b7ff7 Merge pull request #71 from webeled/dev
More examples migrated across.
2013-09-30 04:16:44 -07:00
Richard Davey c5d90a7722 Merge pull request #74 from cottonflop/dev
Fix for incorrect new particle positioning (issue #73)
2013-09-30 03:20:11 -07:00
Richard Davey b0a9c646c9 Merge pull request #76 from XekeDeath/dev
Fix for particles emitting in the wrong area when using emitter.width/height. And small change to make animation looping more robust.
2013-09-30 03:16:33 -07:00
Richard Davey 31bbf05ace * Fixed small bug stopping Tween.pause / resume from resuming correctly when called directly.
* Fixed an issue where Tweens.removeAll wasn't clearing tweens in the addition queue.
* Change: When you swap State all active tweens are now purged.
2013-09-30 11:15:50 +01:00
XekeDeath 62b5aa9bd9 Removed redundant assignment. 2013-09-30 13:28:17 +10:00
XekeDeath ce3e1708e0 Merge branch 'dev' of https://github.com/XekeDeath/phaser into dev 2013-09-30 13:04:29 +10:00
XekeDeath 80e80ddccb Make animation looping robust when skipping frames. 2013-09-30 13:04:22 +10:00
XekeDeath 29dbbcae52 Fix Particle Emitters when using Emitter width/height 2013-09-30 13:02:22 +10:00
Betsy Cottonflop 40b968028a Fix for incorrect new particle positioning 2013-09-28 16:52:37 -07:00
Webeled 8096dc67f5 Corrected few typos and added a keyboard exampl 2013-09-27 18:25:18 +01:00
Webeled efa01dcaa3 Final commit of the day more groups examples 2013-09-27 18:06:36 +01:00
Richard Davey 497d15b5bc Sprite.play 2013-09-27 13:47:22 +01:00
Webeled 903b11b730 Groups examples and some boolean checks corrected 2013-09-27 13:27:15 +01:00
Richard Davey 18c695e9dd PixiPatch and other 1.0.7 features 2013-09-27 09:57:08 +01:00
Richard Davey 6353d8c7ab Fixed some eases. 2013-09-26 15:22:49 +01:00
Richard Davey 9642d4994a 1.0.6a release to fix an issue in the StateManager. 2013-09-26 11:49:58 +01:00
Richard Davey 3a369d5485 Added zwoptex Phaser template. 2013-09-26 11:25:43 +01:00
Richard Davey e77dba402c Beta warning added. 2013-09-24 16:02:58 +01:00
Richard Davey c29fcfb510 1.0.6 release to fix a few important issues and prepare for the dev branch. 2013-09-24 15:53:20 +01:00
Richard Davey 9d84429960 Group length checks 2013-09-24 15:49:21 +01:00
Richard Davey 891369b197 Preparing for 1.0.6 release, but moving physics changes to dev. 2013-09-24 15:28:29 +01:00
Richard Davey 51049128f5 Collision fixes for testing 2013-09-23 22:23:17 +01:00
Richard Davey 257cbe3be8 Much more stable collision, just need to refactor the Tilemap handling - see if I can optimise it a bit too. 2013-09-23 03:26:08 +01:00
Richard Davey bc02a1a05e Fixing collision issues 2013-09-23 01:06:09 +01:00
Richard Davey b69b3db486 1.0.6a 2013-09-22 23:07:12 +01:00
Richard Davey 093bf8343d Graphics fixes and other changes 2013-09-22 22:55:34 +01:00
Richard Davey 02723d4774 Merge pull request #62 from TheJare/fixbmtext
BitmapText fixes
2013-09-22 14:33:16 -07:00
Richard Davey 6b9484aa80 Merge pull request #60 from TheJare/master
Fix bug in StateManager...
2013-09-22 14:32:25 -07:00
Richard Davey f66e6326e3 Merge pull request #61 from powerfear/master
make tweens chainable with .to
2013-09-22 14:13:30 -07:00
Richard Davey 20f63c0af2 Fixed Graphics not working correctly. 2013-09-22 15:22:45 +01:00
Richard Davey 9479c79d79 Merge pull request #63 from luizbills/master
fix antialias bug
2013-09-22 02:14:15 -07:00
TheJare 557160c3c2 Fixes to math library 2013-09-22 03:43:10 +02:00
Luiz "Bills" 8132427870 fix antialias bug 2013-09-21 21:40:36 -03:00
TheJare 15ad941908 Alternative way to specify tile size in spritesheets: negative means how many tiles there are 2013-09-21 19:23:25 +02:00
Richard Davey d1ea96fd83 Input updates 2013-09-21 13:07:06 +01:00
powerfear c36543a261 make tweens chain loopable 2013-09-20 21:47:58 -04:00
TheJare e4595d2a41 Fix box dimensions in PIXI.BitmapText. Support anchor in Phaser.BitmapText 2013-09-21 02:29:14 +02:00
TheJare a4bc69c2f7 Fix box dimensions in PIXI.BitmapText. Support anchor in Phaser.BitmapText 2013-09-21 01:03:19 +01:00
powerfear f31d56584d make tweens chainable with .to
Allow successive .to calls to chain tweens, and an example using it.
2013-09-20 19:14:50 -04:00
Richard Davey 45426be0bc Assets update 2013-09-20 23:21:12 +01:00
TheJare 4b6147d3e3 Fix bug in StateManager where a state's update function might not get called if it has an empty preload function 2013-09-20 22:42:04 +01:00
Richard Davey 8452fa0fd4 Missing assets merged back in! 2013-09-20 17:13:26 +01:00
Richard Davey 68f45709d8 Merge pull request #56 from cocoademon/master
Some small animation fixes
2013-09-20 08:56:49 -07:00
Richard Davey 8c41b3253c 1.0.5 package 2013-09-20 14:00:49 +01:00
Richard Davey a415e779d1 Final 1.0.5 release. 2013-09-20 13:55:33 +01:00
Cameron Foale 61b9e119cb Incorrect input array in FrameData.getFrames 2013-09-20 17:48:38 +10:00
Cameron Foale ec3fc8f307 Fixes numeric frame indexes on animations 2013-09-20 17:39:02 +10:00
Richard Davey 9e88da5c66 Multiple animation fixes in place. 2013-09-19 23:47:50 +01:00
Richard Davey e938e41c73 Merge pull request #54 from webeled/master
Lots of JSDdocs done, and some camera examples
2013-09-19 12:15:26 -07:00
Webeled 1b5c1f18fe More camera examples 2013-09-19 17:47:12 +02:00
Webeled 26a595cd44 JSDocs update ;) 2013-09-19 16:34:48 +02:00
Richard Davey 3f1cafe21f Put the famous idnetityMatrix typo back in so it doesn't break Pixi 2013-09-19 13:33:51 +01:00
Richard Davey 7dd63df087 Merge pull request #52 from cocoademon/master
Make Phaser.Text play nicely with scrolling, by using an explicit x, y
2013-09-19 05:26:22 -07:00
Webeled 78a062dfb6 Updated my files and the documentation checklist 2013-09-19 13:17:49 +02:00
Webeled 6e4631a849 First commit of the day 2013-09-19 10:36:15 +02:00
Cameron Foale 6fde862f61 Make Phaser.Text play nicely with scrolling, by using an explicit x, y 2013-09-19 16:57:19 +10:00
Cameron FoaleandCameron Foale 4f969901da Fixed typo 'indetityMatrix' in RenderTexture 2013-09-19 16:41:34 +10:00
Richard Davey c5fc5e3394 Fixed various issues in the TweenManager, added length property to Group and improved the build script. 2013-09-19 04:45:08 +01:00
Richard Davey cf26f68693 Added Math.numberArray 2013-09-18 14:08:26 +01:00
Richard Davey 47834ad478 Fixed issue in FrameData.getFrameIndexes where the input array was being ignored. 2013-09-18 14:02:31 +01:00
Richard Davey 91c07ea37d Animation delay put back to normal 2013-09-18 06:41:41 +01:00
Richard Davey d9a49797c4 1.0.4 release 2013-09-18 06:34:56 +01:00
Richard Davey a102859622 Added some links to the readme. 2013-09-17 16:59:04 +01:00
Richard Davey a899d24d4c Small readme update 2013-09-17 16:54:46 +01:00
Richard Davey 3c5ea01e09 1.0.3 release - fixed Text and Bitmap Fonts, Animation documentation and more examples 2013-09-17 16:50:47 +01:00
Richard Davey f4734b1143 Merge pull request #46 from webeled/master
jsdocs update plus some audio, button and camera examples.
2013-09-16 13:25:17 -07:00
Webeled bb9761aaf4 It loops but still problems on the constructor 2013-09-16 17:40:56 +02:00
Webeled fc584cf6bc Examples (audio, button,camera), and docs
Created some examples (audio, button,camera), and documented the source
code along the way
2013-09-16 16:37:30 +02:00
Richard Davey 17e208a95e 1.0.2 build 2013-09-16 01:53:53 +01:00
Richard Davey e3869ff3ac * Fixed a bug in the AnimationManager where useNumericIndex was always set to true
* Added in lots of Particle examples
* Added in the start of a Breakout game
* Added in the start of a Platformer game
2013-09-16 01:52:15 +01:00
Richard Davey e705509d29 Added lots of particles examples. 2013-09-16 01:08:06 +01:00
Richard Davey 8c9a7c8bc7 Adding more examples in. 2013-09-15 20:45:00 +01:00
Richard Davey f069107e55 1.0.1 release - fixes issues in tile map collision, additional Animation stop checks and updated package license. 2013-09-15 03:58:38 +01:00
Richard Davey 49a6ba2c02 Updated Group to fix some issues with not checking children 2013-09-15 00:14:45 +01:00
Richard Davey 1bf838a4c4 Final 1.0 push 2013-09-13 18:00:59 +01:00
Richard Davey 48161f5c24 1.0 release versions ready. 2013-09-13 17:52:01 +01:00
Richard Davey 70233b7508 Updating examples with new runner and menu system. 2013-09-13 17:48:47 +01:00
Richard Davey ad0d32b7aa Formatting updates. 2013-09-13 16:42:33 +01:00
Richard Davey 505e808318 Updated README. 2013-09-13 16:34:11 +01:00
Richard Davey 07298c8fcd More tidying up. 2013-09-13 16:24:01 +01:00
Richard Davey f664a4971b Tidying up for 1.0 release push to master. 2013-09-13 16:16:48 +01:00
Richard Davey 7c6e6df91a State swap example done and working. 2013-09-13 05:44:04 +01:00
Richard Davey fd0a071cb3 Added Sprite.centerOn(x,y) and fixed the InputHander snap as a result. 2013-09-13 04:37:06 +01:00
Richard Davey 62d77e7038 Small new demo and refactored collision list - now far less comparisons to perform! 2013-09-13 04:22:12 +01:00
Richard Davey 0a42269479 Group vs. Group collision working - also fixed a bug in the Body.reset function that was causing some lovely physics errors :) 2013-09-13 03:52:05 +01:00
Richard Davey ecc91fb4e0 More collision test cases and fixing a few issues as I go :) 2013-09-13 03:07:39 +01:00
Richard Davey f812b92b8a Creating test cases. 2013-09-13 02:07:58 +01:00
Richard Davey a1450680a4 Part way through re-factoring the collision handler 2013-09-13 00:53:03 +01:00
Richard Davey 9f687b4f8a Adding Type support for collision checks. 2013-09-12 21:54:41 +01:00
Richard Davey 79dc3566f4 Fixed some issues in Tilemap collision, updated the Emitter so x/y controls the point of emission (to stop collision getting out of whack) and fixed the postUpdate in body. 2013-09-12 20:59:56 +01:00
Richard Davey 336de314a1 Fixed an issue where the Tile.physicsElapsed would go insane if the game has been paused for a long time. 2013-09-12 16:18:44 +01:00
Richard Davey 92e86494e3 Tilemap Collision in and working :) Needs testing against Groups now. 2013-09-12 15:39:52 +01:00
Richard Davey d211cf669c Some maps :) 2013-09-12 04:56:33 +01:00
Richard Davey dbaf7269e9 Promoted the Tilemap to a DisplayObject and vastly simplified the load process. 2013-09-12 04:24:01 +01:00
Richard Davey 3d22d0e169 Fixed a bug in the tilemap rendering so the tile offsets were wrong. Now renders perfectly :) Also fixed issue that would cause the World to resize smaller than the game size (not allowed for rendering reasons). 2013-09-12 02:18:23 +01:00
Richard Davey 89b00db103 Tilemap Rendering is working :) 2013-09-12 00:55:27 +01:00
Richard Davey 95374339b9 Added a Sample Plugin and tested out the Plugin Manager. Working great :) 2013-09-11 17:32:53 +01:00
Richard Davey fba731e740 Added optional "pixel perfect" input checks and tested against static sprites, animated sprites, physics sprites and sprites positioned outside the screen (needing camera shift to appear). 2013-09-11 16:25:46 +01:00
Richard Davey f260108433 Tidying up source code for release. Also refactored World to use a Group instance, rather tha duplicate functions. 2013-09-11 13:21:07 +01:00
Richard Davey 87858d6bbf Fixed a bug stopping legacy Audio from starting correctly. Also fixed an issue in the Loader causing it to not load the next file if an unsupported audio file was encountered. Fixed audio playback issues on Firefox/Waterfox as a result. 2013-09-11 11:33:27 +01:00
Richard Davey e79dd5856d Added the ability to crop a sprite with a custom Rectangle. 2013-09-11 03:55:53 +01:00
Richard Davey 48ed27dfcc Finished off RenderTexture. Sprites can now accept a RenderTexture or a key when you create them. RenderTextures are also now stored in the cache under their own key, making re-using them across other Sprites much easier. Also ported over all of the Tilemap classes, but need to get them rendering. 2013-09-11 02:57:36 +01:00
Richard Davey f885f7b023 Added CSS3Filters plugin. Also modified Sprite to contain preUpdate call, so that update can be over-ridden by custom Classes + added an example for this. 2013-09-11 00:35:21 +01:00
Richard Davey e2eddc8b24 Added Full Screen support and tested it. Also added in the BitmapText game object and custom XML loader. Game now sends a pause and resume signal, which the TweenManager listens to and handles correctly. 2013-09-10 23:51:35 +01:00
Richard Davey e41e35fd09 Fixed an error that stopped 2 tweens from being able to run on the same object. Also refactored a lot of the classes to remove prototype properties and move them to local instance properties. 2013-09-10 20:40:34 +01:00
Richard Davey a486bf6b4a Phaser now running on iOS. Also fixed a legacy bug where a pending sound wouldn't play once it was touch unlocked. Also fixed Input not working on WebGL contexts. Added WebGL texture updates to the Group/World swap functions. 2013-09-10 16:46:39 +01:00
Richard Davey 5da0e42be4 Added in the Color Utils and removed the less important functions into ColorHarmony plugin. Updated Stage so backgroundColor can be a string or integer now. 2013-09-10 14:00:46 +01:00
Richard Davey 15fe5ed6c8 Fixed the Bring to Top bug and also fixed Group/World.swap when the child was a tail node. Also improved Group.dump significantly. Fixed Phaser.Utils namespace clash too. 2013-09-10 12:46:14 +01:00
Richard Davey 609ea7ec8f Added ability to Scale particles when emitted. 2013-09-10 11:18:50 +01:00
Richard Davey 4f950ae801 Fixed a fantastic FrameData bug. Also added support to the Emitter to handle multiple image keys and/or frames. 2013-09-10 11:09:25 +01:00
Richard Davey 5d3fe891cd Particle Emitter in and working. Nice and fast, and a lot more flexible than before. 2013-09-10 01:26:50 +01:00
Richard Davey 2ba6b4ff67 Added support for Pointer Lock API. 2013-09-09 19:59:31 +01:00
Richard Davey 60f0e8967f Added Phaser.Graphics and fixed the Out of World Bounds call. 2013-09-09 17:01:59 +01:00
Richard Davey 30fc4099c6 Out of bounds and Sprite events hooked up 2013-09-09 13:29:33 +01:00
Richard Davey ee007cd28e Added in the game scaling handler and updated Stage 2013-09-09 12:35:20 +01:00
Richard Davey c904475ae6 Added in the game scaling handler and updated Stage 2013-09-09 12:35:09 +01:00
Richard Davey 13d6ab512b Fixed the Button frame issue and Down states now work properly 2013-09-09 10:30:01 +01:00
Richard Davey 9b6c819e0e Input Component done and new Button object done and included. Also finished the build script. 2013-09-09 00:30:44 +01:00
Richard Davey 50624c1552 Input Handler working. Dragging, sliding, click detection, multi-touch. Appears to be an issue with bringToTop but it's most likely a problem with the swapChild function rather than Input. 2013-09-08 22:58:15 +01:00
Richard Davey ebda1f99e3 Input Handler 90% there. 2013-09-08 22:38:19 +01:00
Richard Davey abe344b408 More work on the pointer handlers, nearly there! 2013-09-08 17:39:23 +01:00
Richard Davey 90b1946c25 Input Handler mostly restored 2013-09-08 13:23:21 +01:00
Richard Davey 78598ae54a Implemented my own LinkedList class to make the new Input Handler easier to work with. And also just generally useful to have too. 2013-09-08 11:24:41 +01:00
Richard Davey fe6664eac7 Fixed the Body collide issues and optimised the process at the same time. Now the QuadTree appears to work perfectly as a result. Bonus! 2013-09-08 01:24:59 +01:00
Richard Davey bb5d8ca170 a 2013-09-07 21:12:47 +01:00
Richard Davey eb7af3d2a2 Group nearly done. Sprite.anchor appears to be broken though, must fix. 2013-09-06 20:20:58 +01:00
Richard Davey 822a2df289 Lots of work on Group and also resolved the issue of the core game loop structure not being quite right. 2013-09-06 15:00:05 +01:00
Richard Davey 0c97e8e151 Starting work on Group. 2013-09-05 21:07:44 +01:00
Richard Davey b2fa345c9d console banner maker 2013-09-05 03:35:12 +01:00
Richard Davey c552d86639 Added swapChildren to Phaser.World 2013-09-05 02:11:54 +01:00
Richard Davey 4d4f7d3d56 Now working across child sets too :) 2013-09-05 01:57:28 +01:00
Richard Davey aa0d8ff238 Swap Child appears to be working. Time to tested a deeply nested set. 2013-09-05 01:34:22 +01:00
Richard Davey 87d52bd85e Linked List node swap 2013-09-05 01:12:34 +01:00
Richard Davey 912d6e46aa ... 2013-09-05 00:24:01 +01:00
Richard Davey 55cf10a085 LL work 2013-09-04 22:53:13 +01:00
Richard Davey ca0d1eb8af More node manipulations .. nearly there! 2013-09-04 21:34:07 +01:00
Richard Davey f4dab1847e Working on Linked List node swapping. 2013-09-04 21:03:39 +01:00
Richard Davey 10bc22b717 Motion helper functions added to the ArcadePhysics class. 2013-09-04 16:12:58 +01:00
Richard Davey 128bdccd79 Sorted out the QuadTree issues and resolved a small but vital bug in separateX, also re-organised the collision flags in Body. 2013-09-04 13:54:55 +01:00
Richard Davey d44261b191 sublime 2013-09-04 04:59:29 +01:00
Richard Davey b2263c16c6 Patched the QuadTree, now working a whole lot better but am worried it's still working out too many collisions. 2013-09-04 04:54:43 +01:00
Richard Davey 3f3b6bfd35 Brand new highly optimised QuadTree added, populated by the game loop and world ready to be queried as often as you want in your game loop, without creating hundreds of new QuadTrees each frame. 2013-09-04 03:48:15 +01:00
Richard Davey 2a353a0327 Flixel physics optimised about as much as it can be. Also added world and local gravity support and flag to toggle it on / off. 2013-09-04 01:10:01 +01:00
Richard Davey 0f438d5221 separateX up and working sweet with gc spike removal too 2013-09-03 19:34:38 +01:00
Richard Davey a27f6d6562 Forces working, collision half way there. 2013-09-03 17:28:12 +01:00
Richard Davey 2fe8a3a0a7 Physics integration and a fix to Tween that stopped the repeat/yoyo from working. 2013-09-03 17:07:05 +01:00
Richard Davey bdc1c2ceb9 Sorted out the bounds for when sprites are in trimmed texture atlases to stop the physics checks going insane. Also bundled in Advanced Physics lib, although not hooked up yet. 2013-09-03 15:35:40 +01:00
Richard Davey 923c2504ba One more text demo just for fun :) 2013-09-03 06:35:59 +01:00
Richard Davey 8a90a87492 Text converted and a couple of examples created. Using new extend system, so much smaller classes now. 2013-09-03 06:02:47 +01:00
Richard Davey 5acb4e9f1b Borrowed the 'extends' system from jQuery and now the codebase will be considerably smaller :) TileSprite already updated to new format. 2013-09-03 04:58:30 +01:00
Richard Davey e28cdbeb6a Moving to using a small extend / mixin method to avoid code repeating now we're extending Pixi display objects. 2013-09-03 04:43:26 +01:00
Richard Davey 66e86e7d82 Tiling Sprite added 2013-09-03 03:19:42 +01:00
Richard Davey c18de53bab SoundManager converted and playing audio :) 2013-09-03 01:24:16 +01:00
Richard Davey ed13283f0f Tided up the cull / bounds demo. 2013-09-03 00:42:17 +01:00
Richard Davey 7c597999d4 Camera culling now in and working, although you need to enable it on a per sprite basis. Also fixed a few small bugs in the Animation Manager. 2013-09-02 23:22:24 +01:00
Richard Davey 6235f25184 LL 2013-09-01 22:02:42 +01:00
Richard Davey d31777972c Camera culling 2013-09-01 19:52:50 +01:00
Richard Davey 7bdcbf5c2a getBounds update. 2013-09-01 13:17:44 +01:00
Richard Davey 71b4cc532f Added Sprite.getBounds function 2013-09-01 11:15:13 +01:00
Richard Davey d54a92310d Optimised sprite a tiny bit more and created a couple of fun demos :) 2013-09-01 06:21:39 +01:00
Richard Davey fef28c6a6a Optimised update loop to reduce calculations if the transform doesn't change. 2013-09-01 05:50:47 +01:00
Richard Davey 6ef89826df Phew.. lots of transform matrix math over and I can finally get all 4 points of a Sprite, regardless of rotation, translation or scale of itself or any of its parents. 2013-09-01 05:29:53 +01:00
Richard Davey 12e5d2aceb ... 2013-09-01 05:22:08 +01:00
Richard Davey 801c2af9d4 Updated world so the update run uses the linked list. Sprite.getLocalPosition now almost working, but falls over for children. 2013-09-01 03:57:24 +01:00
Richard Davey 188d6239a3 Edge points in and working. 2013-09-01 03:15:27 +01:00
Richard Davey b742439db8 Now handles scaling and rotation. Time to get the offset. 2013-09-01 02:39:26 +01:00
Richard Davey 99e0934244 More late-night math. 2013-09-01 02:28:51 +01:00
Richard Davey 5d4da0ce66 Working out culling 2013-09-01 00:35:29 +01:00
Richard Davey 22847f6ade DebugUtils converted, re-name spaced the Input classes and started on Camera culling. 2013-08-31 21:50:34 +01:00
Richard Davey 70ee753859 The complete Phaser Input Manager suite is now ported across. Not tested in earnest yet, but all the grunt work is at least done. 2013-08-31 13:54:59 +01:00
Richard Davey f9aa7f7339 Fixed small bug in Game where AUTO didn't detect the lack of WebGL properly. Tidied up Math a bit more. 2013-08-30 20:05:29 +01:00
Richard Davey 54d98944e4 Mummy attack :) 2013-08-30 18:56:10 +01:00
Richard Davey e77f5da2cd Fixed the TweenManager and added support to GameObjectFactory, so you can create tweens easily now all hooked in to the internal game clock. Also added the AnimationManager into Sprite, so you can create and play animations directly from sprites nice and easily. 2013-08-30 17:09:43 +01:00
Richard Davey 936118bd91 AnimationManager done and in, need to fix texture update bug, otherwise finished. 2013-08-30 04:20:14 +01:00
Richard Davey a81a8effb4 Sprite Sheets now parse and render correctly too. 2013-08-30 02:18:00 +01:00
Richard Davey 1e59bc69fb Fixed bug in RequestAnimationFrame where the time wasn't being updated properly. 2013-08-30 02:00:30 +01:00
Richard Davey 559d75eba1 When Phaser loads images they are now added to the PIXI.BaseTextureCache. Also when it loads atlas data (regardless of the 3 formats) they are converted into PIXI TextureCache entries using UUIDs to avoid name clashes and to support index based atlases. 2013-08-30 01:50:17 +01:00
Richard Davey 4c1dacfa02 Loader can now parse both JSON Hash and JSON Array formated texture atlas files. 2013-08-29 22:53:55 +01:00
Richard Davey 5b036557c0 The start of World, also moved Game/Stage into core. 2013-08-29 21:57:36 +01:00
Richard Davey 6bf7bab917 Fixed some errors in Rectangle and more Pixi hooks added, now creating the Stage properly and rendering sprites. 2013-08-29 19:20:04 +01:00
Richard Davey 19483bafed Canvas and Stage added and starting to merge in Pixi deeply. 2013-08-29 17:20:59 +01:00
Richard Davey 16749edf20 More state swapping features and optimised Game.loop. 2013-08-29 15:14:56 +01:00
Richard Davey 3d4783980e StateManager improving in leaps and bounds. 2013-08-29 14:38:51 +01:00
Richard Davey 4bbcc380c5 State handling done. Refactored the Game constructor a LOT. Now works from within closures, outside of them, with Phaser.State objects or normal Objects with the right functions inside. Also fixed some small bugs in PluginManager and various scope issues with RAF. 2013-08-29 07:06:16 +01:00
Richard Davey 3c8cd20b70 RequestAnimationFrame done and optimised massively. PluginManager added (but needs testing). Game now fleshed out with all the state changing and core loop, also optimised heavily. Also Pixi integration started and the basics are working well :) 2013-08-29 03:52:59 +01:00
Richard Davey b8d3a61c97 Added the TweenManager 2013-08-29 00:09:12 +01:00
Richard Davey d323404676 Starting integration of tween.js 2013-08-28 21:29:25 +01:00
Richard Davey 8a09469798 Final methods added. 2013-08-28 19:18:34 +01:00
Richard Davey 9289f690eb Rectangle mostly done, needs the prototype functions adding and some test cases made. 2013-08-28 17:19:13 +01:00
Richard Davey 89fe2855e4 Fixed a few things in Circle and added the Point object. 2013-08-28 15:58:37 +01:00
Richard Davey 0f58945212 Circle and Math converted 2013-08-28 15:27:22 +01:00
Richard Davey 09def364c3 Farewell TypeScript, see you on the other side. 2013-08-28 07:02:57 +01:00
Richard Davey 0e55e644a9 Doc updates 2013-08-26 17:45:02 +01:00
Richard Davey 8a85155c08 Fixed the tilemap pre/post update hooks. 2013-08-25 10:35:58 +01:00
Richard Davey ecf61fc80c Updated Game.switchState to accept state objects and fixed the OrientationScreen. 2013-08-25 09:59:23 +01:00
Richard Davey c2745bec35 Pre-vacation push 2013-08-16 23:44:06 +01:00
Richard Davey c884bab7ec Fixed instance check issue in Game and tidied up the stageScaleMode inner loop. 2013-08-16 02:18:12 +01:00
Richard Davey f76ba6840f Animation and Input related fixes 2013-08-16 00:14:57 +01:00
Richard Davey 619b8415ed Reverting back to the only version of TypeScript that really works :( 2013-08-13 04:22:24 +01:00
Richard Davey 91dc7a4acf Tidying up and trying to fix more stupid TypeScript errors. 2013-08-12 04:08:15 +01:00
Richard Davey e74114f384 Docs 2013-08-12 00:52:35 +01:00
Richard Davey 142348f70b Updates 2013-08-11 21:31:35 +01:00
Richard Davey 7aa82a1cb0 All physics projections added. 2013-08-11 19:02:10 +01:00
Richard Davey c2d7fb7fab Merged N+ physics in and tidied up the Docs folder and logos. 2013-08-11 12:15:53 +01:00
Richard Davey aff7d99a8a Fixed bug where children of Groups wouldn't have their preUpdate methods called. 2013-08-09 20:03:36 +01:00
Richard Davey 0b1bcaf270 Set the default camera to direct itself to the Stage. 2013-08-09 18:44:45 +01:00
Richard Davey f9776f30fc Added the CanvasUtils class and moved some stuff out of Stage into it. 2013-08-09 17:47:08 +01:00
Richard Davey 8b2f1cca51 Various small fixes 2013-08-09 17:02:47 +01:00
Richard Davey e002827a20 Fixed load add 2013-08-09 16:56:38 +01:00
Richard Davey c2f0128797 Added types 2013-08-09 16:54:46 +01:00
Richard Davey 2d49a31ecd yuidoc scripts added. Tidied up the Docs folder. Added back in the Emitter and fixed the Tests that weren't compiling. 2013-08-09 05:08:54 +01:00
Richard Davey 9bf7d070f5 Added in the JS source files for doc generation and the definitions to csproj XML script. 2013-08-09 03:12:33 +01:00
Richard Davey 1248a6c06e Whole codebase updated to TypeScript 0.9.1, phew! 2013-08-08 19:16:47 +01:00
Richard Davey df32190db8 Updating for TypeScript 0.9.1, part 1. 2013-08-08 11:34:33 +01:00
Richard Davey 73745e5720 Fixed a few things in Tilemap and optimised the renderer a little bit. 2013-08-08 06:29:21 +01:00
Richard Davey 48f6d850c8 Fixed bug where a Tween with both yoyo and loop enabled would get out of sync. 2013-08-08 06:08:53 +01:00
Richard Davey ab7e55ef27 Added ability for the TimeManager to monitor the pause duration. This is then applied to tweens and other game services, meaning the tweens now restart properly after a pause resumes. 2013-08-08 05:43:22 +01:00
Richard Davey 5768336150 Tidied up the Loader so it now starts automatically, added required Signals and removed the old-style callbacks. 2013-08-08 04:35:13 +01:00
Richard Davey 04dcb29c88 WorldView now takes camera placement into account, so Buttons now work across multiple camera set-ups. 2013-08-08 03:24:26 +01:00
Richard Davey a174bbc6b3 Vastly optimised InputManager and Pointer is now aware of which camera it is over. 2013-08-08 03:05:59 +01:00
Richard Davey bc77c3f84e Updated Renderer system, now much easier to expand and maintain. 2013-08-08 01:07:22 +01:00
Richard Davey d7205992a5 Fixed some issues in dragging sprites with snap-to-center and world coordinates. 2013-08-07 00:00:12 +01:00
Richard Davey 77cc3858d9 Fixed the world drag issue across Sprite and Button. 2013-08-06 04:34:52 +01:00
Richard Davey a7873a3b74 Removed the FX project as it's no longer needed and tidied up the build folder. 2013-08-06 03:43:53 +01:00
Richard Davey 11954812c6 Clearing down the To Do list. 2013-08-06 03:14:48 +01:00
Richard Davey d1da4cbdef Fixed Firefox audio issue with the Loader and added defined functions for anonymous callbacks 2013-08-05 03:43:20 +01:00
Richard Davey 84ef32e62a Fixed Camera FX: Mirror and Scanlines and updated the tests. 2013-08-02 20:03:53 +01:00
Richard Davey f3dcd3e831 Plugin Support added and CameraFX re-enabled 2013-08-02 19:37:43 +01:00
Richard Davey 982faeedb8 Updating and fixing tests 2013-08-02 18:32:26 +01:00
Richard Davey 4c9c50584e Tidying up the physics libraries 2013-08-02 12:38:56 +01:00
Richard Davey 955909979d Preparing for 1.0 branch 2013-08-01 22:21:29 +01:00
Richard Davey ce27acd3ca Merge pull request #41 from pixelpicosean/097
Add typescript files for previous tests and 2 newly created tests.
2013-08-01 14:20:08 -07:00
Richard Davey 4f2c26df77 Fixed issue with Pointer speed not resetting and moved some more render methods to the Debug class. 2013-07-29 00:43:10 +01:00
Richard Davey 3038f6fcf8 Added optimised point in circle test to CircleUtils 2013-07-27 10:57:54 +01:00
Sean d4781a19d9 Add 2 more tests (rectangle utils). 2013-07-27 10:06:10 +08:00
Sean 7cae283a4c Add typescript source for the 46 tests added last time. 2013-07-27 09:59:27 +08:00
Sean 04106b1388 Merge branch 'photonstorm/097' 2013-07-20 10:13:31 +08:00
Richard Davey d80467a08a Some new filter tests added 2013-07-19 17:58:00 +01:00
Richard Davey c8d6fe6c01 Merge branch '097' of https://github.com/pixelpicosean/phaser into pixelpicosean-097 2013-07-19 17:38:55 +01:00
Richard Davey a5343b4bc0 Quick commit before I merge the new tests 2013-07-19 16:53:47 +01:00
Richard Davey 3c123293ba New CSS3 Filters component and Net class. 2013-07-19 04:57:14 +01:00
Richard Davey 9827e7522f Multiple fixes to remove the use of reserved words, making the YUI compressor work again. 2013-07-19 02:59:23 +01:00
Sean 727a06cd9b Merge branch 'photonstorm/097' 2013-07-18 19:25:32 +08:00
Sean 9f30f656bc 46 tests with assets and javascript code. 2013-07-18 15:13:58 +08:00
Richard Davey a2c756e37f Added ability for full Audio tag playback and iOS touch lock load support. 2013-07-16 23:32:47 +01:00
Richard Davey 72eb22128f SoundManager overhaul nearly finished. Proper Web Audio / Audio tag split, working across desktop and mobile. Includes iOS touch unlock restriction handling, auto decoding, global volume management, audio sprite support (for both web audio and audio tags) and playhead monitoring. 2013-07-16 14:45:08 +01:00
Richard Davey d0e886259d Getting ready to overhaul the sound manager. 2013-07-15 21:45:26 +01:00
Sean d620fc7796 Camera tests, some of them not finished because of bugs. 2013-07-13 22:47:32 +08:00
Richard Davey b3fff37faf Added todo items to repo 2013-07-13 12:38:59 +01:00
Sean 08fb303801 Merge remote-tracking branch 'photonstorm/097' into 097 2013-07-13 08:43:28 +08:00
Sean 945c9c1a0d Add assets and code template of camera fx tests. 2013-07-13 08:43:08 +08:00
Sean 6d21d39b19 Fix scrollfactor test for using new component based sprite. 2013-07-13 08:41:05 +08:00
Richard Davey dcce99ec60 Added the new Button game object and various other input and tilemap fixes. 2013-07-12 03:28:46 +01:00
Sean b0d3f6e192 Merge branch 'photonstorm/097' 2013-07-03 07:52:36 +08:00
Richard Davey c81cf0c882 Lots of Tilemap updates, moved the renderer out, added components and new tests. 2013-07-02 23:41:25 +01:00
Sean 4695f62d1d Merge branch 'photonstorm/097' 2013-06-28 06:55:26 +08:00
Richard Davey c647792c12 Physics updates 2013-06-26 14:18:48 +01:00
Richard Davey d19ad4976d Merged Advanced Physics with core. 2013-06-26 05:44:56 +01:00
Richard Davey 0591c7f2bd Doing one final commit before the task of merging physics with core. 2013-06-25 15:35:45 +01:00
Sean 6648cb3812 Merge branch 'photonstorm/097' 2013-06-22 07:42:09 +08:00
Richard Davey ec845155eb After hours and hours of debugging, polygon to polygon collision is now working perfectly :) 2013-06-21 23:39:29 +01:00
Richard Davey 829a1b00e4 Brand new physics system finally (mostly) working. Some poly issues to resolve, but it's running well. 2013-06-18 19:37:09 +01:00
Sean 80f5c0a67d Merge branch 'photonstorm/097' 2013-06-16 09:39:13 +08:00
Richard Davey 0a7513240a Refactor completed. Now to tie the physics and sprites together. 2013-06-14 18:54:12 +01:00
Richard Davey 533a4c2e30 Commiting before a small refactor of Shapes and Joints 2013-06-14 17:55:07 +01:00
Richard Davey dd8962d4b5 After a mammoth debugging session we now have advanced physics colliding and responding accurately :) 2013-06-14 15:18:41 +01:00
Richard Davey 114d1d2fbf Compiling, but not yet running correctly. Need to add body renderer next. 2013-06-14 04:13:00 +01:00
Richard Davey 232c96cc54 Space and Joints interface added. 2013-06-14 03:20:47 +01:00
Richard Davey 461f7ee54d Added lots more classes into the Advanced Physics package 2013-06-14 02:42:51 +01:00
Sean d848fa089d Merge branch 'photonstorm/097' 2013-06-14 08:41:39 +08:00
Sean 1bcbf91398 Add assets for tests and a simple camera scroll test. 2013-06-14 08:36:20 +08:00
Sean 7b6beddc0c Fix assets path. 2013-06-14 08:36:07 +08:00
Richard Davey 038cb213e8 Starting merge of the Advanced Physics classes and splitting off Flixel physics into ArcadePhysics. 2013-06-13 17:15:16 +01:00
Richard Davey 7dac2b6506 Added Group.bringToTop and updated Input component to use sprite getXY handler. 2013-06-13 01:55:32 +01:00
Richard Davey 2389c6c231 Added ability to detect if a given point is within a sprite or not, taking rotation and scaling into account. 2013-06-12 19:53:48 +01:00
Richard Davey c2533d1146 Finally a fully working bounding box that respects scale and rotation - the "in camera" check is now 100% accurate :) 2013-06-11 23:30:35 +01:00
Richard Davey c5f6817c4c Working sprite bounds / vertices regardless of scale or rotation 2013-06-11 21:30:15 +01:00
Richard Davey 1f8c809f53 cameraView working for center rotated sprites, just need to handle any point of rotation. 2013-06-07 19:18:39 +01:00
Richard Davey 3b9386727e Small refactoring and massively optimised the canvas renderer, also added new Mat3 class. 2013-06-07 16:27:33 +01:00
Richard Davey a30762ed8c Fixed world drag support and other input modifications. 2013-06-07 07:35:28 +01:00
Richard Davey 730594835a New Texture and Transform components which are now used by Sprite, Group and Camera. 2013-06-06 02:47:08 +01:00
Richard Davey 2f03f5fc43 Updated Loader component and fixed a few Pointer issues. 2013-06-05 02:58:16 +01:00
Richard Davey d42f396ba0 Lots of tweaks and fixes to the orientation and fullscreen classes 2013-06-05 01:49:08 +01:00
Richard Davey 82d4ba4538 Re-done the pointer handler so it respects the top-most rendered sprite in priority to anything below it, for both mouse over and click events. 2013-06-03 12:03:34 +01:00
Richard Davey 1c37cd1a96 Created DebugUtils class and started moving renderInfo methods to it. 2013-06-03 03:08:24 +01:00
Richard Davey 2de70d07a5 Fixed issue in Camera.inCamera check where it wouldn't take into consideration the Sprites scrollFactor. 2013-06-03 02:38:08 +01:00
Richard Davey b951b02de8 Input priority IDs working properly for drag events. 2013-06-03 01:22:14 +01:00
Richard Davey 2270da2479 Fixed drag sprite + offsets and center locking 2013-06-02 21:41:00 +01:00
Richard Davey f9f17ad353 Multi point input handler working 2013-06-02 14:19:12 +01:00
Richard Davey 49fe5ee65f Added Group IDs and references to Sprites, Group sorting, z-index values and child swapping. Also added all of the drag and bounds methods to Input. 2013-06-02 03:47:54 +01:00
Richard Davey 59f7a59312 Updated docs 2013-06-01 19:59:20 +01:00
Richard Davey 5b532ab2e4 Sprite.Input component added and working nicely. 2013-06-01 02:49:41 +01:00
Richard Davey b20a6ff85a Working my way through putting all the Tests back in and fixing issues as I go. 2013-06-01 01:30:36 +01:00
Richard Davey 31c4d8cb14 Adding in missing tests and fixing as we go 2013-05-31 19:28:16 +01:00
Richard Davey d510b785b1 Putting everything back together again :) 2013-05-31 18:21:32 +01:00
Richard Davey fe372af453 Commit before tidying up redundant files 2013-05-31 15:13:03 +01:00
Richard Davey 23ec3816db Added circleToRect intersection check. 2013-05-31 05:28:36 +01:00
Richard Davey 39e7b84cd9 Flixel level separation merged with the new Physics shapes. 2013-05-31 04:20:49 +01:00
Richard Davey 3e53c0671d About to start re-doing collideShapes 2013-05-30 23:03:56 +01:00
Richard Davey 498725c078 Moved the collision out into separateX and separateY 2013-05-30 13:25:48 +01:00
Richard Davey ce1523585f ScrollZone back in under the new renderer with new demos 2013-05-30 05:34:35 +01:00
Richard Davey f2054f8a2a Physics shape offset now finally working 2013-05-30 03:54:51 +01:00
Richard Davey 0fad46e04b Merged updateMotion with new PhysicsManager 2013-05-30 01:09:27 +01:00
Richard Davey c1eafe865a First pass at integrating the new physics system. 2013-05-29 21:39:08 +01:00
Richard Davey f3c9049e76 Camera updates, scrollFix check and some new pictures and tests. 2013-05-29 17:31:57 +01:00
Richard Davey 7b4374cabf Added loop and yoyo properties to Tweens 2013-05-29 15:45:34 +01:00
Richard Davey b1d836dfaf Scale tweaks 2013-05-29 12:24:25 +01:00
Richard Davey 2a26257caa Fixed scale, flippedX/Y and rotation so they all work from a single setTransform in any combination, taking the origin into account. Phew! 2013-05-29 11:40:05 +01:00
Richard Davey 09f57fa346 Preparing new tests 2013-05-29 02:58:56 +01:00
Richard Davey 3c0c349089 More refactoring for 1.0.0 2013-05-28 21:38:37 +01:00
Richard Davey 03b7467018 Tidying up before putting back together again 2013-05-28 09:37:32 +01:00
Richard Davey 4cef0d1d35 Tidying up 2013-05-25 11:17:11 +01:00
Richard Davey 204ec46b2b Refactoring ready for 1.0 release. 2013-05-25 04:21:24 +01:00
Richard Davey 4ef0750c07 Prep before branch 2013-05-24 01:40:56 +01:00
Richard Davey 67bf221073 Updates 2013-05-23 21:47:29 +01:00
Richard Davey 94add2ea6e Updated Loader so it no longer checks if the animation data is valid, passes that control to the AnimationLoader. Also fixed camera bounds check in Sprite. 2013-05-23 15:45:04 +01:00
Richard Davey c7485301ca Added Starling/Sparrow XML Texture Atlas format support. 2013-05-23 03:08:57 +01:00
Richard Davey c5ace72180 Updated every test to use the new GameObjectFactory syntax 2013-05-23 00:36:53 +01:00
Richard Davey bd54460e80 Added the GameObjectManager 2013-05-23 00:01:58 +01:00
Richard Davey e2141c91a6 Added VerletManager and lots of new tests 2013-05-21 04:12:54 +01:00
Richard Davey 0b2d818ba8 CollisionMask up and running 2013-05-20 06:21:12 +01:00
Richard Davey 05cc32fbc9 Added final logo and start of CollisionMask 2013-05-19 14:01:11 +01:00
Richard Davey 53aa43566e Updated DynamicTexture.setPixel, added GameMath.shuffleArray, fixed Animation.frame and created a few new tests 2013-05-18 03:05:28 +01:00
Richard Davey 55568592b5 Lots of updates across input, rendering and grouping 2013-05-17 06:49:43 +01:00
Richard Davey a6e8436e6d Massive input overhaul continued 2013-05-16 21:34:24 +01:00
Richard Davey 3cdd2baff0 New Input handler implemented. 2013-05-16 02:36:58 +01:00
Richard Davey ce7bfd1fc2 Added FullScreen API support and fixed numerous StageScaleMode issues. 2013-05-14 03:37:38 +01:00
Richard Davey 8fc31ed83b Doc formatting 2013-05-11 23:51:50 +01:00
Sean 1c311a73df Simply add type info to jsdoc of these classs. 2013-05-12 00:26:30 +08:00
Richard Davey 0adbf1d92f Adding more docs :) 2013-05-10 16:31:19 +01:00
Richard Davey aaaaf7ede3 Preparing for doc merge 2013-05-10 16:31:19 +01:00
SeanandRichard Davey 77582fb1ed Re-format optional parameters. 2013-05-10 16:31:18 +01:00
SeanandRichard Davey 2a8447f64e Add some type info to Emitter class. 2013-05-10 16:31:18 +01:00
SeanandRichard Davey deb37e9a90 Finish document for DynamicTexture, Loader, GeomSprite, Sprite, Camera. 2013-05-10 16:31:17 +01:00
SeanandRichard Davey ca932038fb Finish document for ScrollRegion, ScrollZone, Tilemap, Device, TilemapLayer. 2013-05-10 16:31:16 +01:00
SeanandRichard Davey 00ef200914 Finish document for Time, Tween, Animation, AnimationLoader, Frame. 2013-05-10 16:31:16 +01:00
SeanandRichard Davey e88c48641d Finish document for AnimationManager, Tile, FrameData, BootScreen, PauseScreen. 2013-05-10 16:31:15 +01:00
SeanandRichard Davey 1052df6660 Finish documents for Cache, CameraManager, Game, SoundManager, Sound. 2013-05-10 16:31:15 +01:00
SeanandRichard Davey 4be5a10e44 Finish documents for GameObject, World, TweenManager, State, Stage. 2013-05-10 16:31:14 +01:00
SeanandRichard Davey 5cf8b846f8 Finish another 10 classes' document. 2013-05-10 16:31:14 +01:00
SeanandRichard Davey 9da64e6baf Finish document for AnimationManager, CameraManager, SoundManager and TweenManager class. 2013-05-10 16:31:13 +01:00
SeanandRichard Davey 98693cb418 Finish document for Cache, Game, Stage, State and World class. 2013-05-10 16:31:12 +01:00
HackManiacandRichard Davey b1a33cc593 Extended Gruntfile to create phaser-fx.js and phaser-fx.amd.js including declarations 2013-05-10 16:31:12 +01:00
2416 changed files with 735845 additions and 126114 deletions
+16
View File
@@ -1 +1,17 @@
# System and IDE files
Thumbs.db
.DS_Store .DS_Store
.idea
Phaser OSX.sublime-project
Phaser OSX.sublime-workspace
Phaser.sublime-project
Phaser.sublime-workspace
*.suo
*.sublime-project
*.sublime-workspace
# Vendors
node_modules/
# Build
dist/
+75
View File
@@ -0,0 +1,75 @@
{
"globals" : { "Phaser": false, "PIXI": false },
// Ignore Environment Globals
"browser" : true, // Standard browser globals e.g. `window`, `document`.
"couch" : false,
"dojo" : false,
"jquery" : true,
"mootools" : false,
"node" : false,
"nonstandard" : false,
"phantom" : false,
"prototypejs" : false,
"rhino" : false,
"worker" : false,
"wsh" : true, // Windows Scripting Host.
"yui" : false,
// Development
"debug" : true, // Allow debugger statements e.g. browser breakpoints.
"devel" : true, // Allow developments statements e.g. `console.log();`.
// ECMAScript Support
"es3" : true, // Support legacy browser and javascript environments.
"esnext" : false, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
"strict" : false, // Require `use strict` pragma in every file.
"globalstrict" : false, // Allow global "use strict" (also enables 'strict').
// Functionality
"asi" : true, // Tolerate Automatic Semicolon Insertion (no semicolons).
"bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
"boss" : true, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"camelcase" : true, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
"curly" : true, // Require {} for every new block or scope.
"eqeqeq" : false, // Require triple equals i.e. `===`.
"eqnull" : true, // Tolerate use of `== null`.
"evil" : false, // Tolerate use of `eval`.
"expr" : false, // Tolerate `ExpressionStatement` as Programs.
"forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array and Date.
"funcscope" : true, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
"immed" : false, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"iterator" : true, // This option suppresses warnings about the __iterator__ property.
"lastsemic" : true, // This option suppresses warnings about missing semicolons, but only when the semicolon is omitted for the last statement in a one-line block.
"latedef" : false, // Prohipit variable use before definition.
"laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma" : false, // This option suppresses warnings about comma-first coding style.
"loopfunc" : true, // Allow functions to be defined within loops.
// "maxcomplexity" : 10, // This option lets you control cyclomatic complexity throughout your code.
// "maxdepth" : 2, // This option lets you control how nested do you want your blocks to be.
// "maxlen" : 80, // This option lets you set the maximum length of a line.
// "maxparams" : 5, // This option lets you set the max number of formal parameters allowed per function.
// "maxstatements" : 25, // This option lets you set the max number of statements allowed per function.This option lets you set the max number of formal parameters allowed per function.
"moz" : false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
"multistr" : true, // This option suppresses warnings about multi-line strings.
"noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
"notypeof" : false, // This option suppresses warnings about invalid typeof operator values.
"proto" : true, // This option suppresses warnings about the __proto__ property.
"scripturl" : true, // Tolerate script-targeted URLs.
"shadow" : true, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"smarttabs" : false, // This option suppresses warnings about mixed tabs and spaces when the latter are used for alignmnent only.
"supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
"undef" : true, // Require all non-global variables be declared before they are used.
"unused" : true, // This option warns when you define and never use your variables.
"validthis" : true, // This option suppresses warnings about possible strict violations when the code is running in strict mode and you use this in a non-constructor function.
// Styling
"indent" : 4, // Specify indentation spacing
"newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty" : true, // Prohibit use of empty blocks.
"nonew" : true, // Prohibit use of constructors for side-effects.
"plusplus" : false, // Prohibit use of `++` & `--`.
"quotmark" : false, // This option enforces the consistency of quotation marks used throughout your code.
"sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"trailing" : true // Prohibit trailing whitespaces.
}
+72
View File
@@ -0,0 +1,72 @@
#How to contribute
It's important to us that you feel you can contribute towards the evolution of Phaser. This can take many forms: from helping to fix bugs or improve the docs, to adding in new features to the source. This guide should help you in making that process as smooth as possible.
##Reporting issues
[GitHub Issues][0] is the place to report bugs you may have found in either the core library or any of the examples that are part of the repository. When submitting a bug please do the following:
1. **Search for existing issues.** Your bug may have already been fixed or addressed in a development branch version of Phaser, so be sure to search the issues first before putting in a duplicate issue.
2. **Create an isolated and reproducible test case.** If you are reporting a bug, make sure you also have a minimal, runnable, code example that reproduces the problem you have.
3. **Include a live example.** After narrowing your code down to only the problem areas, make use of[jsFiddle][1], [jsBin][2], or a link to your live site so that we can view a live example of the problem.
4. **Share as much information as possible.** Include browser version affected, your OS, version of the library, steps to reproduce, etc. "X isn't working!!!1!" will probably just be closed.
##Pixi and Phaser
It's important to understand that internally Phaser uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) for all rendering. It's possible you may find a bug that is generated on the Pixi level rather than Phaser. You're welcome to still report the issue of course, but if you get a reply saying we think it might be a Pixi issue this is what we're talking about :)
##Support Forum
We have a very active [Phaser Support Forum](http://www.html5gamedevs.com/forum/14-phaser/). If you need general support, or are struggling to understand how to do something or need your code checked over, then we would urge you to post it to our forum. There are a lot of friendly devs in there who can help, as well as the core Phaser and Pixi teams, so it's a great place to get support from. You're welcome to report bugs directly on GitHub, but for general support we'd always recommend using the forum first.
##Dev vs. Master
The dev branch of Phaser is our 'current working' version. It is always ahead of the master branch in terms of features and fixes. However it's also bleeding-edge and experimental and we cannot and do not guarantee it will compile or work for you. Very often we have to break things for a few days while we rebuild and patch. So by all means please export the dev branch and contribute towards it, indeed that is where all Pull Requests should be sent, but do so understanding the API may change beneath you.
##Making Changes
To take advantage of our grunt build script and jshint config it will be easiest for you if you have node.js and grunt installed locally.
You can download node.js from[nodejs.org][3]. After it has been installed open a console and run `npm i - g grunt - cli` to install the global `grunt` executable.
After that you can clone the repository and run `npm i` inside the cloned folder. This will install dependencies necessary for building the project. Once that is ready,
make your changes and submit a Pull Request:
- **Send Pull Requests to the `dev` branch.** All Pull Requests must be sent to the `dev` branch, `master` is the latest release and PRs to that branch will be closed.
- **Ensure changes are jshint validated.** Our JSHint configuration file is provided in the repository and you should check against it before submitting.
- **Never commit new builds.** When making a code change you should always run `grunt` which will rebuild the project so you can test, *however* please do not commit these new builds or your PR will be closed. Builds by default are placed in the `dist` folder, to keep them separate from the `build` folder releases.
- **Only commit relevant changes.** Don't include changes that are not directly relevant to the fix you are making. The more focused a PR is, the faster it will get attention and be merged. Extra files changing only whitespace or trash files will likely get your PR closed.
##I don't really like git / node.js, but I can fix this bug
That is fine too. While Pull Requests are the best thing in the world for us, they are not the only way to help. You're welcome to post fixes to our forum or even just email them to us. All we ask is that you still adhere to the guidelines presented here re: JSHint, etc.
##Code Style Guide
- Use 4 spaces for tabs, never tab characters.
- No trailing whitespace, blank lines should have no whitespace.
- Always favor strict equals` === `unless you * need * to use type coercion.
- Follow conventions already in the code, and listen to jshint. Our config is set-up for a reason.
Thanks to Chad for creating the original Pixi.js Contributing file which we adapted for Phaser.
[0]: https://github.com/photonstorm/phaser/issues
[1]: http://jsfiddle.net
[2]: http://jsbin.com/
[3]: http://nodejs.org
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 531 B

-58
View File
@@ -1,58 +0,0 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-typescript');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
typescript: {
base: {
src: ['Phaser/**/*.ts'],
dest: 'build/phaser.js',
options: {
target: 'ES5'
}
}
},
copy: {
main: {
files: [{
src: 'build/phaser.js',
dest: 'Tests/phaser.js'
}]
},
amd: {
files: [{
src: 'build/phaser.js',
dest: 'build/phaser.amd.js'
}],
options: {
processContent: function(content) {
var replacement = [
'(function (root, factory) {',
' if (typeof exports === \'object\') {',
' module.exports = factory();',
' } else if (typeof define === \'function\' && define.amd) {',
' define(factory);',
' } else {',
' root.Phaser = factory();',
' }',
'}(this, function () {',
content,
'return Phaser;',
'}));'
];
return replacement.join('\n');
}
}
}
},
watch: {
files: '**/*.ts',
tasks: ['typescript', 'copy']
}
});
grunt.registerTask('default', ['watch']);
}
+183
View File
@@ -0,0 +1,183 @@
module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadTasks('./tasks');
grunt.initConfig({
compile_dir: 'dist',
src: {
phaser: [
'src/Intro.js',
'src/pixi/Pixi.js',
'src/Phaser.js',
'src/utils/Utils.js',
'src/pixi/core/Matrix.js',
'src/pixi/core/Point.js',
'src/pixi/core/Rectangle.js',
'src/pixi/core/Polygon.js',
'src/pixi/display/DisplayObject.js',
'src/pixi/display/DisplayObjectContainer.js',
'src/pixi/display/Sprite.js',
'src/pixi/display/Stage.js',
'src/pixi/extras/CustomRenderable.js',
'src/pixi/extras/Strip.js',
'src/pixi/extras/Rope.js',
'src/pixi/extras/TilingSprite.js',
'src/pixi/filters/AbstractFilter.js',
'src/pixi/filters/FilterBlock.js',
'src/pixi/primitives/Graphics.js',
'src/pixi/renderers/canvas/CanvasGraphics.js',
'src/pixi/renderers/canvas/CanvasRenderer.js',
'src/pixi/renderers/webgl/PixiShader.js',
'src/pixi/renderers/webgl/PrimitiveShader.js',
'src/pixi/renderers/webgl/StripShader.js',
'src/pixi/renderers/webgl/WebGLBatch.js',
'src/pixi/renderers/webgl/WebGLFilterManager.js',
'src/pixi/renderers/webgl/WebGLGraphics.js',
'src/pixi/renderers/webgl/WebGLRenderer.js',
'src/pixi/renderers/webgl/WebGLRenderGroup.js',
'src/pixi/renderers/webgl/WebGLShaders.js',
'src/pixi/text/BitmapText.js',
'src/pixi/text/Text.js',
'src/pixi/textures/BaseTexture.js',
'src/pixi/textures/Texture.js',
'src/pixi/textures/RenderTexture.js',
'src/pixi/utils/EventTarget.js',
'src/pixi/utils/Polyk.js',
'src/core/Camera.js',
'src/core/State.js',
'src/core/StateManager.js',
'src/core/LinkedList.js',
'src/core/Signal.js',
'src/core/SignalBinding.js',
'src/core/Filter.js',
'src/core/Plugin.js',
'src/core/PluginManager.js',
'src/core/Stage.js',
'src/core/Group.js',
'src/core/World.js',
'src/core/Game.js',
'src/input/Input.js',
'src/input/Key.js',
'src/input/Keyboard.js',
'src/input/Mouse.js',
'src/input/MSPointer.js',
'src/input/Pointer.js',
'src/input/Touch.js',
'src/input/InputHandler.js',
'src/input/Gamepad.js',
'src/input/SinglePad.js',
'src/input/GamepadButton.js',
'src/gameobjects/Events.js',
'src/gameobjects/GameObjectFactory.js',
'src/gameobjects/BitmapData.js',
'src/gameobjects/Sprite.js',
'src/gameobjects/TileSprite.js',
'src/gameobjects/Text.js',
'src/gameobjects/BitmapText.js',
'src/gameobjects/Button.js',
'src/gameobjects/Graphics.js',
'src/gameobjects/RenderTexture.js',
'src/system/Canvas.js',
'src/system/StageScaleMode.js',
'src/system/Device.js',
'src/system/RequestAnimationFrame.js',
'src/math/RandomDataGenerator.js',
'src/math/Math.js',
'src/math/QuadTree.js',
'src/geom/Circle.js',
'src/geom/Point.js',
'src/geom/Rectangle.js',
'src/geom/Polygon.js',
'src/geom/Line.js',
'src/net/Net.js',
'src/tween/TweenManager.js',
'src/tween/Tween.js',
'src/tween/Easing.js',
'src/time/Time.js',
'src/time/Timer.js',
'src/time/TimerEvent.js',
'src/animation/AnimationManager.js',
'src/animation/Animation.js',
'src/animation/Frame.js',
'src/animation/FrameData.js',
'src/animation/AnimationParser.js',
'src/loader/Cache.js',
'src/loader/Loader.js',
'src/loader/LoaderParser.js',
'src/sound/Sound.js',
'src/sound/SoundManager.js',
'src/utils/Debug.js',
'src/utils/Color.js',
'src/physics/arcade/SAT.js',
'src/physics/arcade/ArcadePhysics.js',
'src/physics/arcade/Body.js',
'src/particles/Particles.js',
'src/particles/arcade/ArcadeParticles.js',
'src/particles/arcade/Emitter.js',
'src/tilemap/Tile.js',
'src/tilemap/Tilemap.js',
'src/tilemap/TilemapLayer.js',
'src/tilemap/TilemapParser.js',
'src/tilemap/Tileset.js',
'src/PixiPatch.js'
]
},
pkg: grunt.file.readJSON('package.json'),
clean: ['<%= compile_dir %>'],
concat: {
phaser: {
options: {
process: {
data: {
version: '<%= pkg.version %>',
buildDate: '<%= grunt.template.today() %>'
}
}
},
src: ['<%= src.phaser %>'],
dest: '<%= compile_dir %>/phaser.js'
}
},
umd: {
phaser: {
src: '<%= concat.phaser.dest %>',
dest: '<%= umd.phaser.src %>'
}
},
uglify: {
phaser: {
options: {
banner: '/*! Phaser v<%= pkg.version %> | (c) 2013 Photon Storm Ltd. */\n'
},
src: ['<%= umd.phaser.dest %>'],
dest: '<%= compile_dir %>/phaser.min.js'
}
},
examples: {
all: {
options: {
base: 'examples',
excludes: ['_site', 'assets', 'states', 'wip']
},
src: ['examples/**/*.js'],
dest: 'examples/_site/examples.json'
}
},
connect: {
root: {
options: {
keepalive: true
}
}
}
});
grunt.registerTask('default', ['build', 'examples']);
grunt.registerTask('build', ['clean', 'concat', 'umd', 'uglify']);
};
-38
View File
@@ -1,38 +0,0 @@
#ignore thumbnails created by windows
Thumbs.db
#Ignore files build by Visual Studio
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.sln
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
*.map
*.orig
*.js
!phaser.js
*.map
*.config
.DS_Store
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
-28
View File
@@ -1,28 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="gameobjects/Sprite.d.ts" />
/// <reference path="system/animation/Animation.d.ts" />
/// <reference path="system/animation/AnimationLoader.d.ts" />
/// <reference path="system/animation/Frame.d.ts" />
/// <reference path="system/animation/FrameData.d.ts" />
module Phaser {
class AnimationManager {
constructor(game: Game, parent: Sprite);
private _game;
private _parent;
private _anims;
private _frameIndex;
private _frameData;
public currentAnim: Animation;
public currentFrame: Frame;
public loadFrameData(frameData: FrameData): void;
public add(name: string, frames?: any[], frameRate?: number, loop?: bool, useNumericIndex?: bool): void;
private validateFrames(frames, useNumericIndex);
public play(name: string, frameRate?: number, loop?: bool): void;
public stop(name: string): void;
public update(): void;
public frameData : FrameData;
public frameTotal : number;
public frame : number;
public frameName : string;
}
}
-186
View File
@@ -1,186 +0,0 @@
/// <reference path="Game.ts" />
/// <reference path="gameobjects/Sprite.ts" />
/// <reference path="system/animation/Animation.ts" />
/// <reference path="system/animation/AnimationLoader.ts" />
/// <reference path="system/animation/Frame.ts" />
/// <reference path="system/animation/FrameData.ts" />
/**
* Phaser - AnimationManager
*
* Any Sprite that has animation contains an instance of the AnimationManager, which is used to add, play and update
* sprite specific animations.
*/
module Phaser {
export class AnimationManager {
constructor(game: Game, parent: Sprite) {
this._game = game;
this._parent = parent;
this._anims = {};
}
private _game: Game;
private _parent: Sprite;
private _anims: {};
private _frameIndex: number;
private _frameData: FrameData = null;
public currentAnim: Animation;
public currentFrame: Frame = null;
public loadFrameData(frameData: FrameData) {
this._frameData = frameData;
this.frame = 0;
}
public add(name: string, frames: any[] = null, frameRate: number = 60, loop: bool = false, useNumericIndex: bool = true) {
if (this._frameData == null)
{
return;
}
if (frames == null)
{
frames = this._frameData.getFrameIndexes();
}
else
{
if (this.validateFrames(frames, useNumericIndex) == false)
{
throw Error('Invalid frames given to Animation ' + name);
return;
}
}
if (useNumericIndex == false)
{
frames = this._frameData.getFrameIndexesByName(frames);
}
this._anims[name] = new Animation(this._game, this._parent, this._frameData, name, frames, frameRate, loop);
this.currentAnim = this._anims[name];
this.currentFrame = this.currentAnim.currentFrame;
}
private validateFrames(frames: any[], useNumericIndex: bool): bool {
for (var i = 0; i < frames.length; i++)
{
if (useNumericIndex == true)
{
if (frames[i] > this._frameData.total)
{
return false;
}
}
else
{
if (this._frameData.checkFrameName(frames[i]) == false)
{
return false;
}
}
}
return true;
}
public play(name: string, frameRate?: number = null, loop?: bool) {
if (this._anims[name])
{
if (this.currentAnim == this._anims[name])
{
if (this.currentAnim.isPlaying == false)
{
this.currentAnim.play(frameRate, loop);
}
}
else
{
this.currentAnim = this._anims[name];
this.currentAnim.play(frameRate, loop);
}
}
}
public stop(name: string) {
if (this._anims[name])
{
this.currentAnim = this._anims[name];
this.currentAnim.stop();
}
}
public update() {
if (this.currentAnim && this.currentAnim.update() == true)
{
this.currentFrame = this.currentAnim.currentFrame;
this._parent.bounds.width = this.currentFrame.width;
this._parent.bounds.height = this.currentFrame.height;
}
}
public get frameData(): FrameData {
return this._frameData;
}
public get frameTotal(): number {
return this._frameData.total;
}
public get frame(): number {
return this._frameIndex;
}
public set frame(value: number) {
if (this._frameData.getFrame(value) !== null)
{
this.currentFrame = this._frameData.getFrame(value);
this._parent.bounds.width = this.currentFrame.width;
this._parent.bounds.height = this.currentFrame.height;
this._frameIndex = value;
}
}
public get frameName(): string {
return this.currentFrame.name;
}
public set frameName(value: string) {
if (this._frameData.getFrameByName(value) !== null)
{
this.currentFrame = this._frameData.getFrameByName(value);
this._parent.bounds.width = this.currentFrame.width;
this._parent.bounds.height = this.currentFrame.height;
this._frameIndex = this.currentFrame.index;
}
}
}
}
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class Basic {
constructor(game: Game);
public _game: Game;
public name: string;
public ID: number;
public isGroup: bool;
public exists: bool;
public active: bool;
public visible: bool;
public alive: bool;
public ignoreDrawDebug: bool;
public destroy(): void;
public preUpdate(): void;
public update(): void;
public postUpdate(): void;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
public kill(): void;
public revive(): void;
public toString(): string;
}
}
-138
View File
@@ -1,138 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - Basic
*
* A useful "generic" object on which all GameObjects and Groups are based.
* It has no size, position or graphical data.
*/
module Phaser {
export class Basic {
/**
* Instantiate the basic object.
*/
constructor(game: Game) {
this._game = game;
this.ID = -1;
this.exists = true;
this.active = true;
this.visible = true;
this.alive = true;
this.isGroup = false;
this.ignoreDrawDebug = false;
}
/**
* The essential reference to the main game object
*/
public _game: Game;
/**
* Allows you to give this object a name. Useful for debugging, but not actually used internally.
*/
public name: string = '';
/**
* IDs seem like they could be pretty useful, huh?
* They're not actually used for anything yet though.
*/
public ID: number;
/**
* A boolean to store if this object is a Group or not.
* Saves us an expensive typeof check inside of core loops.
*/
public isGroup: bool;
/**
* Controls whether <code>update()</code> and <code>draw()</code> are automatically called by State/Group.
*/
public exists: bool;
/**
* Controls whether <code>update()</code> is automatically called by State/Group.
*/
public active: bool;
/**
* Controls whether <code>draw()</code> is automatically called by State/Group.
*/
public visible: bool;
/**
* Useful state for many game objects - "dead" (!alive) vs alive.
* <code>kill()</code> and <code>revive()</code> both flip this switch (along with exists, but you can override that).
*/
public alive: bool;
/**
* Setting this to true will prevent the object from appearing
* when the visual debug mode in the debugger overlay is toggled on.
*/
public ignoreDrawDebug: bool;
/**
* Override this to null out iables or manually call
* <code>destroy()</code> on class members if necessary.
* Don't forget to call <code>super.destroy()</code>!
*/
public destroy() { }
/**
* Pre-update is called right before <code>update()</code> on each object in the game loop.
*/
public preUpdate() {
}
/**
* Override this to update your class's position and appearance.
* This is where most of your game rules and behavioral code will go.
*/
public update() {
}
/**
* Post-update is called right after <code>update()</code> on each object in the game loop.
*/
public postUpdate() {
}
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
}
/**
* Handy for "killing" game objects.
* Default behavior is to flag them as nonexistent AND dead.
* However, if you want the "corpse" to remain in the game,
* like to animate an effect or whatever, you should override this,
* setting only alive to false, and leaving exists true.
*/
public kill() {
this.alive = false;
this.exists = false;
}
/**
* Handy for bringing game objects "back to life". Just sets alive and exists back to true.
* In practice, this is most often called by <code>Object.reset()</code>.
*/
public revive() {
this.alive = true;
this.exists = true;
}
/**
* Convert object to readable string name. Useful for debugging, save games, etc.
*/
public toString(): string {
return "";
}
}
}
-26
View File
@@ -1,26 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class Cache {
constructor(game: Game);
private _game;
private _canvases;
private _images;
private _sounds;
private _text;
public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void;
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number): void;
public addTextureAtlas(key: string, url: string, data, jsonData): void;
public addImage(key: string, url: string, data): void;
public addSound(key: string, url: string, data): void;
public decodedSound(key: string, data): void;
public addText(key: string, url: string, data): void;
public getCanvas(key: string);
public getImage(key: string);
public getFrameData(key: string): FrameData;
public getSound(key: string);
public isSoundDecoded(key: string): bool;
public isSpriteSheet(key: string): bool;
public getText(key: string);
public destroy(): void;
}
}
-176
View File
@@ -1,176 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - Cache
*
* A game only has one instance of a Cache and it is used to store all externally loaded assets such
* as images, sounds and data files as a result of Loader calls. Cache items use string based keys for look-up.
*/
module Phaser {
export class Cache {
constructor(game: Game) {
this._game = game;
this._canvases = {};
this._images = {};
this._sounds = {};
this._text = {};
}
private _game: Game;
private _canvases;
private _images;
private _sounds;
private _text;
public addCanvas(key: string, canvas: HTMLCanvasElement, context: CanvasRenderingContext2D) {
this._canvases[key] = { canvas: canvas, context: context };
}
public addSpriteSheet(key: string, url: string, data, frameWidth: number, frameHeight: number, frameMax: number) {
this._images[key] = { url: url, data: data, spriteSheet: true, frameWidth: frameWidth, frameHeight: frameHeight };
this._images[key].frameData = AnimationLoader.parseSpriteSheet(this._game, key, frameWidth, frameHeight, frameMax);
}
public addTextureAtlas(key: string, url: string, data, jsonData) {
this._images[key] = { url: url, data: data, spriteSheet: true };
this._images[key].frameData = AnimationLoader.parseJSONData(this._game, jsonData);
}
public addImage(key: string, url: string, data) {
this._images[key] = { url: url, data: data, spriteSheet: false };
}
public addSound(key: string, url: string, data) {
this._sounds[key] = { url: url, data: data, decoded: false };
}
public decodedSound(key: string, data) {
this._sounds[key].data = data;
this._sounds[key].decoded = true;
}
public addText(key: string, url: string, data) {
this._text[key] = { url: url, data: data };
}
public getCanvas(key: string) {
if (this._canvases[key])
{
return this._canvases[key].canvas;
}
return null;
}
public getImage(key: string) {
if (this._images[key])
{
return this._images[key].data;
}
return null;
}
public getFrameData(key: string): FrameData {
if (this._images[key] && this._images[key].spriteSheet == true)
{
return this._images[key].frameData;
}
return null;
}
public getSound(key: string) {
if (this._sounds[key])
{
return this._sounds[key].data;
}
return null;
}
public isSoundDecoded(key: string): bool {
if (this._sounds[key])
{
return this._sounds[key].decoded;
}
}
public isSpriteSheet(key: string): bool {
if (this._images[key])
{
return this._images[key].spriteSheet;
}
}
public getText(key: string) {
if (this._text[key])
{
return this._text[key].data;
}
return null;
}
public destroy() {
for (var item in this._canvases)
{
delete this._canvases[item['key']];
}
for (var item in this._images)
{
delete this._images[item['key']];
}
for (var item in this._sounds)
{
delete this._sounds[item['key']];
}
for (var item in this._text)
{
delete this._text[item['key']];
}
}
}
}
-17
View File
@@ -1,17 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="system/Camera.d.ts" />
module Phaser {
class CameraManager {
constructor(game: Game, x: number, y: number, width: number, height: number);
private _game;
private _cameras;
private _cameraInstance;
public current: Camera;
public getAll(): Camera[];
public update(): void;
public render(): void;
public addCamera(x: number, y: number, width: number, height: number): Camera;
public removeCamera(id: number): bool;
public destroy(): void;
}
}
-89
View File
@@ -1,89 +0,0 @@
/// <reference path="Game.ts" />
/// <reference path="system/Camera.ts" />
/**
* Phaser - CameraManager
*
* Your game only has one CameraManager instance and it's responsible for looking after, creating and destroying
* all of the cameras in the world.
*
* TODO: If the Camera is larger than the Stage size then the rotation offset isn't correct
* TODO: Texture Repeat doesn't scroll, because it's part of the camera not the world, need to think about this more
*/
module Phaser {
export class CameraManager {
constructor(game: Game, x: number, y: number, width: number, height: number) {
this._game = game;
this._cameras = [];
this.current = this.addCamera(x, y, width, height);
}
private _game: Game;
private _cameras: Camera[];
private _cameraInstance: number = 0;
public current: Camera;
public getAll(): Camera[] {
return this._cameras;
}
public update() {
this._cameras.forEach((camera) => camera.update());
}
public render() {
this._cameras.forEach((camera) => camera.render());
}
public addCamera(x: number, y: number, width: number, height: number): Camera {
var newCam: Camera = new Camera(this._game, this._cameraInstance, x, y, width, height);
this._cameras.push(newCam);
this._cameraInstance++;
return newCam;
}
public removeCamera(id: number): bool {
for (var c = 0; c < this._cameras.length; c++)
{
if (this._cameras[c].ID == id)
{
if (this.current.ID === this._cameras[c].ID)
{
this.current = null;
}
this._cameras.splice(c, 1);
return true;
}
}
return false;
}
public destroy() {
this._cameras.length = 0;
this.current = this.addCamera(0, 0, this._game.stage.width, this._game.stage.height);
}
}
}
-53
View File
@@ -1,53 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="geom/Point.d.ts" />
/// <reference path="geom/Rectangle.d.ts" />
/// <reference path="geom/Quad.d.ts" />
/// <reference path="geom/Circle.d.ts" />
/// <reference path="geom/Line.d.ts" />
/// <reference path="geom/IntersectResult.d.ts" />
/// <reference path="system/QuadTree.d.ts" />
module Phaser {
class Collision {
constructor(game: Game);
private _game;
static LEFT: number;
static RIGHT: number;
static UP: number;
static DOWN: number;
static NONE: number;
static CEILING: number;
static FLOOR: number;
static WALL: number;
static ANY: number;
static OVERLAP_BIAS: number;
static TILE_OVERLAP: bool;
static _tempBounds: Quad;
static lineToLine(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
static lineToLineSegment(line: Line, seg: Line, output?: IntersectResult): IntersectResult;
static lineToRawSegment(line: Line, x1: number, y1: number, x2: number, y2: number, output?: IntersectResult): IntersectResult;
static lineToRay(line1: Line, ray: Line, output?: IntersectResult): IntersectResult;
static lineToCircle(line: Line, circle: Circle, output?: IntersectResult): IntersectResult;
static lineToRectangle(line: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
static lineSegmentToLineSegment(line1: Line, line2: Line, output?: IntersectResult): IntersectResult;
static lineSegmentToRay(line: Line, ray: Line, output?: IntersectResult): IntersectResult;
static lineSegmentToCircle(seg: Line, circle: Circle, output?: IntersectResult): IntersectResult;
static lineSegmentToRectangle(seg: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
static rayToRectangle(ray: Line, rect: Rectangle, output?: IntersectResult): IntersectResult;
static rayToLineSegment(rayX1, rayY1, rayX2, rayY2, lineX1, lineY1, lineX2, lineY2, output?: IntersectResult): IntersectResult;
static pointToRectangle(point, rect: Rectangle, output?: IntersectResult): IntersectResult;
static rectangleToRectangle(rect1: Rectangle, rect2: Rectangle, output?: IntersectResult): IntersectResult;
static rectangleToCircle(rect: Rectangle, circle: Circle, output?: IntersectResult): IntersectResult;
static circleToCircle(circle1: Circle, circle2: Circle, output?: IntersectResult): IntersectResult;
static circleToRectangle(circle: Circle, rect: Rectangle, output?: IntersectResult): IntersectResult;
static circleContainsPoint(circle: Circle, point, output?: IntersectResult): IntersectResult;
public overlap(object1?: Basic, object2?: Basic, notifyCallback?, processCallback?): bool;
static separate(object1, object2): bool;
static separateTile(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool, collideUp: bool, collideDown: bool): bool;
static separateTileX(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideLeft: bool, collideRight: bool): bool;
static separateTileY(object: GameObject, x: number, y: number, width: number, height: number, mass: number, collideUp: bool, collideDown: bool): bool;
static separateX(object1, object2): bool;
static separateY(object1, object2): bool;
static distance(x1: number, y1: number, x2: number, y2: number): number;
static distanceSquared(x1: number, y1: number, x2: number, y2: number): number;
}
}
-1056
View File
File diff suppressed because it is too large Load Diff
-32
View File
@@ -1,32 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class DynamicTexture {
constructor(game: Game, width: number, height: number);
private _game;
private _sx;
private _sy;
private _sw;
private _sh;
private _dx;
private _dy;
private _dw;
private _dh;
public bounds: Rectangle;
public canvas: HTMLCanvasElement;
public context: CanvasRenderingContext2D;
public getPixel(x: number, y: number): number;
public getPixel32(x: number, y: number): number;
public getPixels(rect: Rectangle): ImageData;
public setPixel(x: number, y: number, color: number): void;
public setPixel32(x: number, y: number, color: number): void;
public setPixels(rect: Rectangle, input): void;
public fillRect(rect: Rectangle, color: number): void;
public pasteImage(key: string, frame?: number, destX?: number, destY?: number, destWidth?: number, destHeight?: number): void;
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point): void;
public clear(): void;
public width : number;
public height : number;
private getColor32(alpha, red, green, blue);
private getColor(red, green, blue);
}
}
-217
View File
@@ -1,217 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - DynamicTexture
*
* A DynamicTexture can be thought of as a mini canvas into which you can draw anything.
* Game Objects can be assigned a DynamicTexture, so when they render in the world they do so
* based on the contents of the texture at the time. This allows you to create powerful effects
* once and have them replicated across as many game objects as you like.
*/
module Phaser {
export class DynamicTexture {
constructor(game: Game, width: number, height: number) {
this._game = game;
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
this.canvas.width = width;
this.canvas.height = height;
this.context = this.canvas.getContext('2d');
this.bounds = new Rectangle(0, 0, width, height);
}
private _game: Game;
private _sx: number = 0;
private _sy: number = 0;
private _sw: number = 0;
private _sh: number = 0;
private _dx: number = 0;
private _dy: number = 0;
private _dw: number = 0;
private _dh: number = 0;
// Input / Output nodes?
public bounds: Rectangle;
public canvas: HTMLCanvasElement;
public context: CanvasRenderingContext2D;
public getPixel(x: number, y: number): number {
//r = imageData.data[0];
//g = imageData.data[1];
//b = imageData.data[2];
//a = imageData.data[3];
var imageData = this.context.getImageData(x, y, 1, 1);
return this.getColor(imageData.data[0], imageData.data[1], imageData.data[2]);
}
public getPixel32(x: number, y: number) {
var imageData = this.context.getImageData(x, y, 1, 1);
return this.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
}
// Returns a CanvasPixelArray
public getPixels(rect: Rectangle) {
return this.context.getImageData(rect.x, rect.y, rect.width, rect.height);
}
public setPixel(x: number, y: number, color: number) {
this.context.fillStyle = color;
this.context.fillRect(x, y, 1, 1);
}
public setPixel32(x: number, y: number, color: number) {
this.context.fillStyle = color;
this.context.fillRect(x, y, 1, 1);
}
public setPixels(rect: Rectangle, input) {
this.context.putImageData(input, rect.x, rect.y);
}
public fillRect(rect: Rectangle, color: number) {
this.context.fillStyle = color;
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
}
public pasteImage(key: string, frame?: number = -1, destX?: number = 0, destY?: number = 0, destWidth?: number = null, destHeight?: number = null) {
var texture = null;
var frameData;
this._sx = 0;
this._sy = 0;
this._dx = destX;
this._dy = destY;
// TODO - Load a frame from a sprite sheet, otherwise we'll draw the whole lot
if (frame > -1)
{
//if (this._game.cache.isSpriteSheet(key))
//{
// texture = this._game.cache.getImage(key);
//this.animations.loadFrameData(this._game.cache.getFrameData(key));
//}
}
else
{
texture = this._game.cache.getImage(key);
this._sw = texture.width;
this._sh = texture.height;
this._dw = texture.width;
this._dh = texture.height;
}
if (destWidth !== null)
{
this._dw = destWidth;
}
if (destHeight !== null)
{
this._dh = destHeight;
}
if (texture != null)
{
this.context.drawImage(
texture, // Source Image
this._sx, // Source X (location within the source image)
this._sy, // Source Y
this._sw, // Source Width
this._sh, // Source Height
this._dx, // Destination X (where on the canvas it'll be drawn)
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
}
}
// TODO - Add in support for: alphaBitmapData: BitmapData = null, alphaPoint: Point = null, mergeAlpha: bool = false
public copyPixels(sourceTexture: DynamicTexture, sourceRect: Rectangle, destPoint: Point) {
// Swap for drawImage if the sourceRect is the same size as the sourceTexture to avoid a costly getImageData call
if (sourceRect.equals(this.bounds) == true)
{
this.context.drawImage(sourceTexture.canvas, destPoint.x, destPoint.y);
}
else
{
this.context.putImageData(sourceTexture.getPixels(sourceRect), destPoint.x, destPoint.y);
}
}
public clear() {
this.context.clearRect(0, 0, this.bounds.width, this.bounds.height);
}
public get width(): number {
return this.bounds.width;
}
public get height(): number {
return this.bounds.height;
}
/**
* Given an alpha and 3 color values this will return an integer representation of it
*
* @param alpha The Alpha value (between 0 and 255)
* @param red The Red channel value (between 0 and 255)
* @param green The Green channel value (between 0 and 255)
* @param blue The Blue channel value (between 0 and 255)
*
* @return A native color value integer (format: 0xAARRGGBB)
*/
private getColor32(alpha: number, red: number, green: number, blue: number): number {
return alpha << 24 | red << 16 | green << 8 | blue;
}
/**
* Given 3 color values this will return an integer representation of it
*
* @param red The Red channel value (between 0 and 255)
* @param green The Green channel value (between 0 and 255)
* @param blue The Blue channel value (between 0 and 255)
*
* @return A native color value integer (format: 0xRRGGBB)
*/
private getColor(red: number, green: number, blue: number): number {
return red << 16 | green << 8 | blue;
}
}
}
-18
View File
@@ -1,18 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class FXManager {
constructor(game: Game);
private _fx;
private _length;
private _game;
public active: bool;
public visible: bool;
public add(effect): any;
public preUpdate(): void;
public postUpdate(): void;
public preRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
public render(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
public postRender(camera: Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number): void;
public destroy(): void;
}
}
-220
View File
@@ -1,220 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - FXManager
*
* The FXManager controls all special effects applied to game objects such as Cameras.
*/
module Phaser {
export class FXManager {
constructor(game: Game, parent) {
this._game = game;
this._parent = parent;
this._fx = [];
this.active = true;
this.visible = true;
}
/**
* The essential reference to the main game object.
*/
private _game: Game;
/**
* A reference to the object that owns this FXManager instance.
*/
private _parent;
/**
* The array in which we keep all of the registered FX
*/
private _fx;
/**
* Holds the size of the _fx array
*/
private _length: number;
/**
* Controls whether any of the FX have preUpdate, update or postUpdate called
*/
public active: bool;
/**
* Controls whether any of the FX have preRender, render or postRender called
*/
public visible: bool;
/**
* Adds a new FX to the FXManager.
* The effect must be an object with at least one of the following methods: preUpdate, postUpdate, preRender, render or postRender.
* A new instance of the effect will be created and a reference to Game will be passed to the object constructor.
*/
public add(effect): any {
var result: bool = false;
var newEffect = { effect: {}, preUpdate: false, postUpdate: false, preRender: false, render: false, postRender: false };
if (typeof effect === 'function')
{
newEffect.effect = new effect(this._game, this._parent);
}
else
{
throw new Error("Invalid object given to Phaser.FXManager.add");
}
// Check for methods now to avoid having to do this every loop
if (typeof newEffect.effect['preUpdate'] === 'function')
{
newEffect.preUpdate = true;
result = true;
}
if (typeof newEffect.effect['postUpdate'] === 'function')
{
newEffect.postUpdate = true;
result = true;
}
if (typeof newEffect.effect['preRender'] === 'function')
{
newEffect.preRender = true;
result = true;
}
if (typeof newEffect.effect['render'] === 'function')
{
newEffect.render = true;
result = true;
}
if (typeof newEffect.effect['postRender'] === 'function')
{
newEffect.postRender = true;
result = true;
}
if (result == true)
{
this._length = this._fx.push(newEffect);
return newEffect.effect;
}
else
{
return result;
}
}
/**
* Pre-update is called at the start of the objects update cycle, before any other updates have taken place.
*/
public preUpdate() {
if (this.active)
{
for (var i = 0; i < this._length; i++)
{
if (this._fx[i].preUpdate)
{
this._fx[i].effect.preUpdate();
}
}
}
}
/**
* Post-update is called at the end of the objects update cycle, after other update logic has taken place.
*/
public postUpdate() {
if (this.active)
{
for (var i = 0; i < this._length; i++)
{
if (this._fx[i].postUpdate)
{
this._fx[i].effect.postUpdate();
}
}
}
}
/**
* Pre-render is called at the start of the object render cycle, before any transforms have taken place.
* It happens directly AFTER a canvas context.save has happened if added to a Camera.
*/
public preRender(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
if (this.visible)
{
for (var i = 0; i < this._length; i++)
{
if (this._fx[i].preRender)
{
this._fx[i].effect.preRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
}
}
}
}
/**
* render is called during the objects render cycle, right after all transforms have finished, but before any children/image data is rendered.
*/
public render(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
if (this.visible)
{
for (var i = 0; i < this._length; i++)
{
if (this._fx[i].preRender)
{
this._fx[i].effect.preRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
}
}
}
}
/**
* Post-render is called during the objects render cycle, after the children/image data has been rendered.
* It happens directly BEFORE a canvas context.restore has happened if added to a Camera.
*/
public postRender(camera:Camera, cameraX: number, cameraY: number, cameraWidth: number, cameraHeight: number) {
if (this.visible)
{
for (var i = 0; i < this._length; i++)
{
if (this._fx[i].postRender)
{
this._fx[i].effect.postRender(camera, cameraX, cameraY, cameraWidth, cameraHeight);
}
}
}
}
/**
* Clear down this FXManager and null out references
*/
public destroy() {
this._game = null;
this._fx = null;
}
}
}
-88
View File
@@ -1,88 +0,0 @@
/// <reference path="AnimationManager.d.ts" />
/// <reference path="Basic.d.ts" />
/// <reference path="Cache.d.ts" />
/// <reference path="CameraManager.d.ts" />
/// <reference path="Collision.d.ts" />
/// <reference path="DynamicTexture.d.ts" />
/// <reference path="FXManager.d.ts" />
/// <reference path="GameMath.d.ts" />
/// <reference path="Group.d.ts" />
/// <reference path="Loader.d.ts" />
/// <reference path="Motion.d.ts" />
/// <reference path="Signal.d.ts" />
/// <reference path="SignalBinding.d.ts" />
/// <reference path="SoundManager.d.ts" />
/// <reference path="Stage.d.ts" />
/// <reference path="Time.d.ts" />
/// <reference path="TweenManager.d.ts" />
/// <reference path="World.d.ts" />
/// <reference path="system/Device.d.ts" />
/// <reference path="system/RandomDataGenerator.d.ts" />
/// <reference path="system/RequestAnimationFrame.d.ts" />
/// <reference path="system/input/Input.d.ts" />
/// <reference path="system/input/Keyboard.d.ts" />
/// <reference path="system/input/Mouse.d.ts" />
/// <reference path="system/input/Touch.d.ts" />
/// <reference path="gameobjects/Emitter.d.ts" />
/// <reference path="gameobjects/GameObject.d.ts" />
/// <reference path="gameobjects/GeomSprite.d.ts" />
/// <reference path="gameobjects/Particle.d.ts" />
/// <reference path="gameobjects/Sprite.d.ts" />
/// <reference path="gameobjects/Tilemap.d.ts" />
/// <reference path="gameobjects/ScrollZone.d.ts" />
module Phaser {
class Game {
constructor(callbackContext, parent?: string, width?: number, height?: number, initCallback?, createCallback?, updateCallback?, renderCallback?);
private _raf;
private _maxAccumulation;
private _accumulator;
private _step;
private _loadComplete;
private _paused;
private _pendingState;
public callbackContext;
public onInitCallback;
public onCreateCallback;
public onUpdateCallback;
public onRenderCallback;
public onPausedCallback;
public cache: Cache;
public collision: Collision;
public input: Input;
public loader: Loader;
public math: GameMath;
public motion: Motion;
public sound: SoundManager;
public stage: Stage;
public time: Time;
public tweens: TweenManager;
public world: World;
public rnd: RandomDataGenerator;
public device: Device;
public isBooted: bool;
public isRunning: bool;
private boot(parent, width, height);
private loadComplete();
private bootLoop();
private pausedLoop();
private loop();
private startState();
public setCallbacks(initCallback?, createCallback?, updateCallback?, renderCallback?): void;
public switchState(state, clearWorld?: bool, clearCache?: bool): void;
public destroy(): void;
public paused : bool;
public framerate : number;
public createCamera(x: number, y: number, width: number, height: number): Camera;
public createGeomSprite(x: number, y: number): GeomSprite;
public createSprite(x: number, y: number, key?: string): Sprite;
public createDynamicTexture(width: number, height: number): DynamicTexture;
public createGroup(MaxSize?: number): Group;
public createParticle(): Particle;
public createEmitter(x?: number, y?: number, size?: number): Emitter;
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
public createTween(obj): Tween;
public collide(objectOrGroup1?: Basic, objectOrGroup2?: Basic, notifyCallback?): bool;
public camera : Camera;
}
}
-451
View File
@@ -1,451 +0,0 @@
/// <reference path="AnimationManager.ts" />
/// <reference path="Basic.ts" />
/// <reference path="Cache.ts" />
/// <reference path="CameraManager.ts" />
/// <reference path="Collision.ts" />
/// <reference path="DynamicTexture.ts" />
/// <reference path="FXManager.ts" />
/// <reference path="GameMath.ts" />
/// <reference path="Group.ts" />
/// <reference path="Loader.ts" />
/// <reference path="Motion.ts" />
/// <reference path="Signal.ts" />
/// <reference path="SignalBinding.ts" />
/// <reference path="SoundManager.ts" />
/// <reference path="Stage.ts" />
/// <reference path="Time.ts" />
/// <reference path="TweenManager.ts" />
/// <reference path="World.ts" />
/// <reference path="system/Device.ts" />
/// <reference path="system/RandomDataGenerator.ts" />
/// <reference path="system/RequestAnimationFrame.ts" />
/// <reference path="system/input/Input.ts" />
/// <reference path="system/input/Keyboard.ts" />
/// <reference path="system/input/Mouse.ts" />
/// <reference path="system/input/Touch.ts" />
/// <reference path="gameobjects/Emitter.ts" />
/// <reference path="gameobjects/GameObject.ts" />
/// <reference path="gameobjects/GeomSprite.ts" />
/// <reference path="gameobjects/Particle.ts" />
/// <reference path="gameobjects/Sprite.ts" />
/// <reference path="gameobjects/Tilemap.ts" />
/// <reference path="gameobjects/ScrollZone.ts" />
/**
* Phaser - Game
*
* This is where the magic happens. The Game object is the heart of your game,
* providing quick access to common functions and handling the boot process.
*
* "Hell, there are no rules here - we're trying to accomplish something."
* Thomas A. Edison
*/
module Phaser {
export class Game {
constructor(callbackContext, parent?: string = '', width?: number = 800, height?: number = 600, initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
this.callbackContext = callbackContext;
this.onInitCallback = initCallback;
this.onCreateCallback = createCallback;
this.onUpdateCallback = updateCallback;
this.onRenderCallback = renderCallback;
if (document.readyState === 'complete' || document.readyState === 'interactive')
{
setTimeout(() => this.boot(parent, width, height));
}
else
{
document.addEventListener('DOMContentLoaded', () => this.boot(parent, width, height), false);
window.addEventListener('load', () => this.boot(parent, width, height), false);
}
}
private _raf: RequestAnimationFrame;
private _maxAccumulation: number = 32;
private _accumulator: number = 0;
private _step: number = 0;
private _loadComplete: bool = false;
private _paused: bool = false;
private _pendingState = null;
// Event callbacks
public callbackContext;
public onInitCallback = null;
public onCreateCallback = null;
public onUpdateCallback = null;
public onRenderCallback = null;
public onPausedCallback = null;
public cache: Cache;
public collision: Collision;
public input: Input;
public loader: Loader;
public math: GameMath;
public motion: Motion;
public sound: SoundManager;
public stage: Stage;
public time: Time;
public tweens: TweenManager;
public world: World;
public rnd: RandomDataGenerator;
public device: Device;
public isBooted: bool = false;
public isRunning: bool = false;
private boot(parent: string, width: number, height: number) {
if (this.isBooted == true)
{
return;
}
if (!document.body)
{
window.setTimeout(() => this.boot(parent, width, height), 13);
}
else
{
this.device = new Device();
this.motion = new Motion(this);
this.math = new GameMath(this);
this.stage = new Stage(this, parent, width, height);
this.world = new World(this, width, height);
this.sound = new SoundManager(this);
this.cache = new Cache(this);
this.collision = new Collision(this);
this.loader = new Loader(this, this.loadComplete);
this.time = new Time(this);
this.tweens = new TweenManager(this);
this.input = new Input(this);
this.rnd = new RandomDataGenerator([(Date.now() * Math.random()).toString()]);
this.framerate = 60;
this.isBooted = true;
// Display the default game screen?
if (this.onInitCallback == null && this.onCreateCallback == null && this.onUpdateCallback == null && this.onRenderCallback == null && this._pendingState == null)
{
this._raf = new RequestAnimationFrame(this.bootLoop, this);
}
else
{
this.isRunning = true;
this._loadComplete = false;
this._raf = new RequestAnimationFrame(this.loop, this);
if (this._pendingState)
{
this.switchState(this._pendingState, false, false);
}
else
{
this.startState();
}
}
}
}
private loadComplete() {
// Called when the loader has finished after init was run
this._loadComplete = true;
}
private bootLoop() {
this.time.update();
this.tweens.update();
this.input.update();
this.stage.update();
}
private pausedLoop() {
this.time.update();
this.tweens.update();
this.input.update();
this.stage.update();
if (this.onPausedCallback !== null)
{
this.onPausedCallback.call(this.callbackContext);
}
}
private loop() {
this.time.update();
this.tweens.update();
this.input.update();
this.stage.update();
this._accumulator += this.time.delta;
if (this._accumulator > this._maxAccumulation)
{
this._accumulator = this._maxAccumulation;
}
while (this._accumulator >= this._step)
{
this.time.elapsed = this.time.timeScale * (this._step / 1000);
this.world.update();
this._accumulator = this._accumulator - this._step;
}
if (this._loadComplete && this.onUpdateCallback)
{
this.onUpdateCallback.call(this.callbackContext);
}
this.world.render();
if (this._loadComplete && this.onRenderCallback)
{
this.onRenderCallback.call(this.callbackContext);
}
}
private startState() {
if (this.onInitCallback !== null)
{
this.loader.reset();
this.onInitCallback.call(this.callbackContext);
// Is the loader empty?
if (this.loader.queueSize == 0)
{
if (this.onCreateCallback !== null)
{
this.onCreateCallback.call(this.callbackContext);
}
this._loadComplete = true;
}
}
else
{
// No init? Then there was nothing to load either
if (this.onCreateCallback !== null)
{
this.onCreateCallback.call(this.callbackContext);
}
this._loadComplete = true;
}
}
public setCallbacks(initCallback = null, createCallback = null, updateCallback = null, renderCallback = null) {
this.onInitCallback = initCallback;
this.onCreateCallback = createCallback;
this.onUpdateCallback = updateCallback;
this.onRenderCallback = renderCallback;
}
public switchState(state, clearWorld: bool = true, clearCache: bool = false) {
if (this.isBooted == false)
{
this._pendingState = state;
return;
}
// Prototype?
if (typeof state === 'function')
{
state = new state(this);
}
// Ok, have we got the right functions?
if (state['create'] || state['update'])
{
this.callbackContext = state;
this.onInitCallback = null;
this.onCreateCallback = null;
this.onUpdateCallback = null;
this.onRenderCallback = null;
this.onPausedCallback = null;
// Bingo, let's set them up
if (state['init'])
{
this.onInitCallback = state['init'];
}
if (state['create'])
{
this.onCreateCallback = state['create'];
}
if (state['update'])
{
this.onUpdateCallback = state['update'];
}
if (state['render'])
{
this.onRenderCallback = state['render'];
}
if (state['paused'])
{
this.onPausedCallback = state['paused'];
}
if (clearWorld)
{
this.world.destroy();
if (clearCache == true)
{
this.cache.destroy();
}
}
this._loadComplete = false;
this.startState();
}
else
{
throw new Error("Invalid State object given. Must contain at least a create or update function.");
}
}
// Nuke the whole game from orbit
public destroy() {
this.callbackContext = null;
this.onInitCallback = null;
this.onCreateCallback = null;
this.onUpdateCallback = null;
this.onRenderCallback = null;
this.onPausedCallback = null;
this.cache = null;
this.input = null;
this.loader = null;
this.sound = null;
this.stage = null;
this.time = null;
this.world = null;
this.isBooted = false;
}
public get paused(): bool {
return this._paused;
}
public set paused(value: bool) {
if (value == true && this._paused == false)
{
this._paused = true;
this._raf.setCallback(this.pausedLoop);
}
else if (value == false && this._paused == true)
{
this._paused = false;
this.time.time = Date.now();
this.input.reset();
if (this.isRunning == false)
{
this._raf.setCallback(this.bootLoop);
}
else
{
this._raf.setCallback(this.loop);
}
}
}
public get framerate(): number {
return 1000 / this._step;
}
public set framerate(value: number) {
this._step = 1000 / value;
if (this._maxAccumulation < this._step)
{
this._maxAccumulation = this._step;
}
}
// Handy Proxy methods
public createCamera(x: number, y: number, width: number, height: number): Camera {
return this.world.createCamera(x, y, width, height);
}
public createGeomSprite(x: number, y: number): GeomSprite {
return this.world.createGeomSprite(x, y);
}
public createSprite(x: number, y: number, key?: string = ''): Sprite {
return this.world.createSprite(x, y, key);
}
public createDynamicTexture(width: number, height: number): DynamicTexture {
return this.world.createDynamicTexture(width, height);
}
public createGroup(MaxSize?: number = 0): Group {
return this.world.createGroup(MaxSize);
}
public createParticle(): Particle {
return this.world.createParticle();
}
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
return this.world.createEmitter(x, y, size);
}
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return this.world.createScrollZone(key, x, y, width, height);
}
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
return this.world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight);
}
public createTween(obj): Tween {
return this.tweens.create(obj);
}
public collide(objectOrGroup1: Basic = null, objectOrGroup2: Basic = null, notifyCallback = null): bool {
return this.collision.overlap(objectOrGroup1, objectOrGroup2, notifyCallback, Collision.separate);
}
public get camera(): Camera {
return this.world.cameras.current;
}
}
}
-110
View File
@@ -1,110 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class GameMath {
constructor(game: Game);
private _game;
static PI: number;
static PI_2: number;
static PI_4: number;
static PI_8: number;
static PI_16: number;
static TWO_PI: number;
static THREE_PI_2: number;
static E: number;
static LN10: number;
static LN2: number;
static LOG10E: number;
static LOG2E: number;
static SQRT1_2: number;
static SQRT2: number;
static DEG_TO_RAD: number;
static RAD_TO_DEG: number;
static B_16: number;
static B_31: number;
static B_32: number;
static B_48: number;
static B_53: number;
static B_64: number;
static ONE_THIRD: number;
static TWO_THIRDS: number;
static ONE_SIXTH: number;
static COS_PI_3: number;
static SIN_2PI_3: number;
static CIRCLE_ALPHA: number;
static ON: bool;
static OFF: bool;
static SHORT_EPSILON: number;
static PERC_EPSILON: number;
static EPSILON: number;
static LONG_EPSILON: number;
public cosTable: any[];
public sinTable: any[];
public fuzzyEqual(a: number, b: number, epsilon?: number): bool;
public fuzzyLessThan(a: number, b: number, epsilon?: number): bool;
public fuzzyGreaterThan(a: number, b: number, epsilon?: number): bool;
public fuzzyCeil(val: number, epsilon?: number): number;
public fuzzyFloor(val: number, epsilon?: number): number;
public average(...args: any[]): number;
public slam(value: number, target: number, epsilon?: number): number;
public percentageMinMax(val: number, max: number, min?: number): number;
public sign(n: number): number;
public truncate(n: number): number;
public shear(n: number): number;
public wrap(val: number, max: number, min?: number): number;
public arithWrap(value: number, max: number, min?: number): number;
public clamp(input: number, max: number, min?: number): number;
public snapTo(input: number, gap: number, start?: number): number;
public snapToFloor(input: number, gap: number, start?: number): number;
public snapToCeil(input: number, gap: number, start?: number): number;
public snapToInArray(input: number, arr: number[], sort?: bool): number;
public roundTo(value: number, place?: number, base?: number): number;
public floorTo(value: number, place?: number, base?: number): number;
public ceilTo(value: number, place?: number, base?: number): number;
public interpolateFloat(a: number, b: number, weight: number): number;
public radiansToDegrees(angle: number): number;
public degreesToRadians(angle: number): number;
public angleBetween(x1: number, y1: number, x2: number, y2: number): number;
public normalizeAngle(angle: number, radians?: bool): number;
public nearestAngleBetween(a1: number, a2: number, radians?: bool): number;
public normalizeAngleToAnother(dep: number, ind: number, radians?: bool): number;
public normalizeAngleAfterAnother(dep: number, ind: number, radians?: bool): number;
public normalizeAngleBeforeAnother(dep: number, ind: number, radians?: bool): number;
public interpolateAngles(a1: number, a2: number, weight: number, radians?: bool, ease?): number;
public logBaseOf(value: number, base: number): number;
public GCD(m: number, n: number): number;
public LCM(m: number, n: number): number;
public factorial(value: number): number;
public gammaFunction(value: number): number;
public fallingFactorial(base: number, exp: number): number;
public risingFactorial(base: number, exp: number): number;
public binCoef(n: number, k: number): number;
public risingBinCoef(n: number, k: number): number;
public chanceRoll(chance?: number): bool;
public maxAdd(value: number, amount: number, max: number): number;
public minSub(value: number, amount: number, min: number): number;
public wrapValue(value: number, amount: number, max: number): number;
public randomSign(): number;
public isOdd(n: number): bool;
public isEven(n: number): bool;
public wrapAngle(angle: number): number;
public angleLimit(angle: number, min: number, max: number): number;
public linearInterpolation(v, k);
public bezierInterpolation(v, k): number;
public catmullRomInterpolation(v, k);
public linear(p0, p1, t);
public bernstein(n, i): number;
public catmullRom(p0, p1, p2, p3, t);
public difference(a: number, b: number): number;
public globalSeed: number;
public random(): number;
public srand(Seed: number): number;
public getRandom(Objects, StartIndex?: number, Length?: number);
public floor(Value: number): number;
public ceil(Value: number): number;
public sinCosGenerator(length: number, sinAmplitude?: number, cosAmplitude?: number, frequency?: number): any[];
public shiftSinTable(): number;
public shiftCosTable(): number;
public vectorLength(dx: number, dy: number): number;
public dotProduct(ax: number, ay: number, bx: number, by: number): number;
}
}
-39
View File
@@ -1,39 +0,0 @@
/// <reference path="Basic.d.ts" />
/// <reference path="Game.d.ts" />
module Phaser {
class Group extends Basic {
constructor(game: Game, MaxSize?: number);
static ASCENDING: number;
static DESCENDING: number;
public members: Basic[];
public length: number;
private _maxSize;
private _marker;
private _sortIndex;
private _sortOrder;
public destroy(): void;
public update(): void;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
public maxSize : number;
public add(Object: Basic): Basic;
public recycle(ObjectClass?);
public remove(Object: Basic, Splice?: bool): Basic;
public replace(OldObject: Basic, NewObject: Basic): Basic;
public sort(Index?: string, Order?: number): void;
public setAll(VariableName: string, Value: Object, Recurse?: bool): void;
public callAll(FunctionName: string, Recurse?: bool): void;
public forEach(callback, recursive?: bool): void;
public forEachAlive(context, callback, recursive?: bool): void;
public getFirstAvailable(ObjectClass?);
public getFirstNull(): number;
public getFirstExtant(): Basic;
public getFirstAlive(): Basic;
public getFirstDead(): Basic;
public countLiving(): number;
public countDead(): number;
public getRandom(StartIndex?: number, Length?: number): Basic;
public clear(): void;
public kill(): void;
public sortHandler(Obj1: Basic, Obj2: Basic): number;
}
}
-769
View File
@@ -1,769 +0,0 @@
/// <reference path="Basic.ts" />
/// <reference path="Game.ts" />
/**
* Phaser - Group
*
* This class is used for organising, updating and sorting game objects.
*
*/
module Phaser {
export class Group extends Basic {
constructor(game: Game, MaxSize?: number = 0) {
super(game);
this.isGroup = true;
this.members = [];
this.length = 0;
this._maxSize = MaxSize;
this._marker = 0;
this._sortIndex = null;
}
/**
* Use with <code>sort()</code> to sort in ascending order.
*/
public static ASCENDING: number = -1;
/**
* Use with <code>sort()</code> to sort in descending order.
*/
public static DESCENDING: number = 1;
/**
* Array of all the <code>Basic</code>s that exist in this group.
*/
public members: Basic[];
/**
* The number of entries in the members array.
* For performance and safety you should check this variable
* instead of members.length unless you really know what you're doing!
*/
public length: number;
/**
* Internal tracker for the maximum capacity of the group.
* Default is 0, or no max capacity.
*/
private _maxSize: number;
/**
* Internal helper variable for recycling objects a la <code>Emitter</code>.
*/
private _marker: number;
/**
* Helper for sort.
*/
private _sortIndex: string;
/**
* Helper for sort.
*/
private _sortOrder: number;
/**
* Override this function to handle any deleting or "shutdown" type operations you might need,
* such as removing traditional Flash children like Basic objects.
*/
public destroy() {
if (this.members != null)
{
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null)
{
basic.destroy();
}
}
this.members.length = 0;
}
this._sortIndex = null;
}
/**
* Automatically goes through and calls update on everything you added.
*/
public update() {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && basic.exists && basic.active)
{
basic.preUpdate();
basic.update();
basic.postUpdate();
}
}
}
/**
* Automatically goes through and calls render on everything you added.
*/
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && basic.exists && basic.visible)
{
basic.render(camera, cameraOffsetX, cameraOffsetY);
}
}
}
/**
* The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.
*/
public get maxSize(): number {
return this._maxSize;
}
/**
* @private
*/
public set maxSize(Size: number) {
this._maxSize = Size;
if (this._marker >= this._maxSize)
{
this._marker = 0;
}
if ((this._maxSize == 0) || (this.members == null) || (this._maxSize >= this.members.length))
{
return;
}
//If the max size has shrunk, we need to get rid of some objects
var basic: Basic;
var i: number = this._maxSize;
var l: number = this.members.length;
while (i < l)
{
basic = this.members[i++];
if (basic != null)
{
basic.destroy();
}
}
this.length = this.members.length = this._maxSize;
}
/**
* Adds a new <code>Basic</code> subclass (Basic, Basic, Enemy, etc) to the group.
* Group will try to replace a null member of the array first.
* Failing that, Group will add it to the end of the member array,
* assuming there is room for it, and doubling the size of the array if necessary.
*
* <p>WARNING: If the group has a maxSize that has already been met,
* the object will NOT be added to the group!</p>
*
* @param Object The object you want to add to the group.
*
* @return The same <code>Basic</code> object that was passed in.
*/
public add(Object: Basic) {
//Don't bother adding an object twice.
if (this.members.indexOf(Object) >= 0)
{
return Object;
}
//First, look for a null entry where we can add the object.
var i: number = 0;
var l: number = this.members.length;
while (i < l)
{
if (this.members[i] == null)
{
this.members[i] = Object;
if (i >= this.length)
{
this.length = i + 1;
}
return Object;
}
i++;
}
//Failing that, expand the array (if we can) and add the object.
if (this._maxSize > 0)
{
if (this.members.length >= this._maxSize)
{
return Object;
}
else if (this.members.length * 2 <= this._maxSize)
{
this.members.length *= 2;
}
else
{
this.members.length = this._maxSize;
}
}
else
{
this.members.length *= 2;
}
//If we made it this far, then we successfully grew the group,
//and we can go ahead and add the object at the first open slot.
this.members[i] = Object;
this.length = i + 1;
return Object;
}
/**
* Recycling is designed to help you reuse game objects without always re-allocating or "newing" them.
*
* <p>If you specified a maximum size for this group (like in Emitter),
* then recycle will employ what we're calling "rotating" recycling.
* Recycle() will first check to see if the group is at capacity yet.
* If group is not yet at capacity, recycle() returns a new object.
* If the group IS at capacity, then recycle() just returns the next object in line.</p>
*
* <p>If you did NOT specify a maximum size for this group,
* then recycle() will employ what we're calling "grow-style" recycling.
* Recycle() will return either the first object with exists == false,
* or, finding none, add a new object to the array,
* doubling the size of the array if necessary.</p>
*
* <p>WARNING: If this function needs to create a new object,
* and no object class was provided, it will return null
* instead of a valid object!</p>
*
* @param ObjectClass The class type you want to recycle (e.g. Basic, EvilRobot, etc). Do NOT "new" the class in the parameter!
*
* @return A reference to the object that was created. Don't forget to cast it back to the Class you want (e.g. myObject = myGroup.recycle(myObjectClass) as myObjectClass;).
*/
public recycle(ObjectClass = null) {
var basic;
if (this._maxSize > 0)
{
if (this.length < this._maxSize)
{
if (ObjectClass == null)
{
return null;
}
return this.add(new ObjectClass(this._game));
}
else
{
basic = this.members[this._marker++];
if (this._marker >= this._maxSize)
{
this._marker = 0;
}
return basic;
}
}
else
{
basic = this.getFirstAvailable(ObjectClass);
if (basic != null)
{
return basic;
}
if (ObjectClass == null)
{
return null;
}
return this.add(new ObjectClass(this._game));
}
}
/**
* Removes an object from the group.
*
* @param object The <code>Basic</code> you want to remove.
* @param splice Whether the object should be cut from the array entirely or not.
*
* @return The removed object.
*/
public remove(object: Basic, splice: bool = false): Basic {
var index: number = this.members.indexOf(object);
if ((index < 0) || (index >= this.members.length))
{
return null;
}
if (splice)
{
this.members.splice(index, 1);
this.length--;
}
else
{
this.members[index] = null;
}
return object;
}
/**
* Replaces an existing <code>Basic</code> with a new one.
*
* @param oldObject The object you want to replace.
* @param newObject The new object you want to use instead.
*
* @return The new object.
*/
public replace(oldObject: Basic, newObject: Basic): Basic {
var index: number = this.members.indexOf(oldObject);
if ((index < 0) || (index >= this.members.length))
{
return null;
}
this.members[index] = newObject;
return newObject;
}
/**
* Call this function to sort the group according to a particular value and order.
* For example, to sort game objects for Zelda-style overlaps you might call
* <code>myGroup.sort("y",Group.ASCENDING)</code> at the bottom of your
* <code>State.update()</code> override. To sort all existing objects after
* a big explosion or bomb attack, you might call <code>myGroup.sort("exists",Group.DESCENDING)</code>.
*
* @param index The <code>string</code> name of the member variable you want to sort on. Default value is "y".
* @param order A <code>Group</code> constant that defines the sort order. Possible values are <code>Group.ASCENDING</code> and <code>Group.DESCENDING</code>. Default value is <code>Group.ASCENDING</code>.
*/
public sort(index: string = "y", order: number = Group.ASCENDING) {
this._sortIndex = index;
this._sortOrder = order;
this.members.sort(this.sortHandler);
}
/**
* Go through and set the specified variable to the specified value on all members of the group.
*
* @param VariableName The string representation of the variable name you want to modify, for example "visible" or "scrollFactor".
* @param Value The value you want to assign to that variable.
* @param Recurse Default value is true, meaning if <code>setAll()</code> encounters a member that is a group, it will call <code>setAll()</code> on that group rather than modifying its variable.
*/
public setAll(VariableName: string, Value: Object, Recurse: bool = true) {
var basic: Basic;
var i: number = 0;
while (i < length)
{
basic = this.members[i++];
if (basic != null)
{
if (Recurse && (basic.isGroup == true))
{
<Group> basic['setAll'](VariableName, Value, Recurse);
}
else
{
basic[VariableName] = Value;
}
}
}
}
/**
* Go through and call the specified function on all members of the group.
* Currently only works on functions that have no required parameters.
*
* @param FunctionName The string representation of the function you want to call on each object, for example "kill()" or "init()".
* @param Recurse Default value is true, meaning if <code>callAll()</code> encounters a member that is a group, it will call <code>callAll()</code> on that group rather than calling the group's function.
*/
public callAll(FunctionName: string, Recurse: bool = true) {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null)
{
if (Recurse && (basic.isGroup == true))
{
<Group> basic['callAll'](FunctionName, Recurse);
}
else
{
basic[FunctionName]();
}
}
}
}
public forEach(callback, recursive: bool = false) {
var basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null)
{
if (recursive && (basic.isGroup == true))
{
basic.forEach(callback, true);
}
else
{
callback.call(this, basic);
}
}
}
}
public forEachAlive(context, callback, recursive: bool = false) {
var basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null && basic.alive)
{
if (recursive && (basic.isGroup == true))
{
basic.forEachAlive(context, callback, true);
}
else
{
callback.call(context, basic);
}
}
}
}
/**
* Call this function to retrieve the first object with exists == false in the group.
* This is handy for recycling in general, e.g. respawning enemies.
*
* @param ObjectClass An optional parameter that lets you narrow the results to instances of this particular class.
*
* @return A <code>Basic</code> currently flagged as not existing.
*/
public getFirstAvailable(ObjectClass = null) {
var basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && !basic.exists && ((ObjectClass == null) || (typeof basic === ObjectClass)))
{
return basic;
}
}
return null;
}
/**
* Call this function to retrieve the first index set to 'null'.
* Returns -1 if no index stores a null object.
*
* @return An <code>int</code> indicating the first null slot in the group.
*/
public getFirstNull(): number {
var basic: Basic;
var i: number = 0;
var l: number = this.members.length;
while (i < l)
{
if (this.members[i] == null)
{
return i;
}
else
{
i++;
}
}
return -1;
}
/**
* Call this function to retrieve the first object with exists == true in the group.
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
*
* @return A <code>Basic</code> currently flagged as existing.
*/
public getFirstExtant(): Basic {
var basic: Basic;
var i: number = 0;
while (i < length)
{
basic = this.members[i++];
if ((basic != null) && basic.exists)
{
return basic;
}
}
return null;
}
/**
* Call this function to retrieve the first object with dead == false in the group.
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
*
* @return A <code>Basic</code> currently flagged as not dead.
*/
public getFirstAlive(): Basic {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && basic.exists && basic.alive)
{
return basic;
}
}
return null;
}
/**
* Call this function to retrieve the first object with dead == true in the group.
* This is handy for checking if everything's wiped out, or choosing a squad leader, etc.
*
* @return A <code>Basic</code> currently flagged as dead.
*/
public getFirstDead(): Basic {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && !basic.alive)
{
return basic;
}
}
return null;
}
/**
* Call this function to find out how many members of the group are not dead.
*
* @return The number of <code>Basic</code>s flagged as not dead. Returns -1 if group is empty.
*/
public countLiving(): number {
var count: number = -1;
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null)
{
if (count < 0)
{
count = 0;
}
if (basic.exists && basic.alive)
{
count++;
}
}
}
return count;
}
/**
* Call this function to find out how many members of the group are dead.
*
* @return The number of <code>Basic</code>s flagged as dead. Returns -1 if group is empty.
*/
public countDead(): number {
var count: number = -1;
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if (basic != null)
{
if (count < 0)
{
count = 0;
}
if (!basic.alive)
{
count++;
}
}
}
return count;
}
/**
* Returns a member at random from the group.
*
* @param StartIndex Optional offset off the front of the array. Default value is 0, or the beginning of the array.
* @param Length Optional restriction on the number of values you want to randomly select from.
*
* @return A <code>Basic</code> from the members list.
*/
public getRandom(StartIndex: number = 0, Length: number = 0): Basic {
if (Length == 0)
{
Length = this.length;
}
return this._game.math.getRandom(this.members, StartIndex, Length);
}
/**
* Remove all instances of <code>Basic</code> subclass (Basic, Block, etc) from the list.
* WARNING: does not destroy() or kill() any of these objects!
*/
public clear() {
this.length = this.members.length = 0;
}
/**
* Calls kill on the group's members and then on the group itself.
*/
public kill() {
var basic: Basic;
var i: number = 0;
while (i < this.length)
{
basic = this.members[i++];
if ((basic != null) && basic.exists)
{
basic.kill();
}
}
}
/**
* Helper function for the sort process.
*
* @param Obj1 The first object being sorted.
* @param Obj2 The second object being sorted.
*
* @return An integer value: -1 (Obj1 before Obj2), 0 (same), or 1 (Obj1 after Obj2).
*/
public sortHandler(Obj1: Basic, Obj2: Basic): number {
if (Obj1[this._sortIndex] < Obj2[this._sortIndex])
{
return this._sortOrder;
}
else if (Obj1[this._sortIndex] > Obj2[this._sortIndex])
{
return -this._sortOrder;
}
return 0;
}
}
}
-34
View File
@@ -1,34 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class Loader {
constructor(game: Game, callback);
private _game;
private _keys;
private _fileList;
private _gameCreateComplete;
private _onComplete;
private _onFileLoad;
private _progressChunk;
private _xhr;
private _queueSize;
public hasLoaded: bool;
public progress: number;
public reset(): void;
public queueSize : number;
public addImageFile(key: string, url: string): void;
public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number): void;
public addTextureAtlas(key: string, url: string, jsonURL?: string, jsonData?): void;
public addAudioFile(key: string, url: string): void;
public addTextFile(key: string, url: string): void;
public removeFile(key: string): void;
public removeAll(): void;
public load(onFileLoadCallback?, onCompleteCallback?): void;
private loadFile();
private fileError(key);
private fileComplete(key);
private jsonLoadComplete(key);
private jsonLoadError(key);
private nextFile(previousKey, success);
private checkKeyExists(key);
}
}
-347
View File
@@ -1,347 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - Loader
*
* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
* It uses a combination of Image() loading and xhr and provides for progress and completion callbacks.
*/
module Phaser {
export class Loader {
constructor(game: Game, callback) {
this._game = game;
this._gameCreateComplete = callback;
this._keys = [];
this._fileList = {};
this._xhr = new XMLHttpRequest();
this._queueSize = 0;
}
private _game: Game;
private _keys: string[];
private _fileList;
private _gameCreateComplete;
private _onComplete;
private _onFileLoad;
private _progressChunk: number;
private _xhr: XMLHttpRequest;
private _queueSize: number;
public hasLoaded: bool;
public progress: number;
public reset() {
this._queueSize = 0;
}
public get queueSize(): number {
return this._queueSize;
}
public addImageFile(key: string, url: string) {
if (this.checkKeyExists(key) === false)
{
this._queueSize++;
this._fileList[key] = { type: 'image', key: key, url: url, data: null, error: false, loaded: false };
this._keys.push(key);
}
}
public addSpriteSheet(key: string, url: string, frameWidth: number, frameHeight: number, frameMax?: number = -1) {
if (this.checkKeyExists(key) === false)
{
this._queueSize++;
this._fileList[key] = { type: 'spritesheet', key: key, url: url, data: null, frameWidth: frameWidth, frameHeight: frameHeight, frameMax: frameMax, error: false, loaded: false };
this._keys.push(key);
}
}
public addTextureAtlas(key: string, url: string, jsonURL?: string = null, jsonData? = null) {
if (this.checkKeyExists(key) === false)
{
if (jsonURL !== null)
{
// A URL to a json file has been given
this._queueSize++;
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: jsonURL, jsonData: null, error: false, loaded: false };
this._keys.push(key);
}
else
{
// A json string or object has been given
if (typeof jsonData === 'string')
{
var data = JSON.parse(jsonData);
// Malformed?
if (data['frames'])
{
this._queueSize++;
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: data['frames'], error: false, loaded: false };
this._keys.push(key);
}
}
else
{
// Malformed?
if (jsonData['frames'])
{
this._queueSize++;
this._fileList[key] = { type: 'textureatlas', key: key, url: url, data: null, jsonURL: null, jsonData: jsonData['frames'], error: false, loaded: false };
this._keys.push(key);
}
}
}
}
}
public addAudioFile(key: string, url: string) {
if (this.checkKeyExists(key) === false)
{
this._queueSize++;
this._fileList[key] = { type: 'audio', key: key, url: url, data: null, buffer: null, error: false, loaded: false };
this._keys.push(key);
}
}
public addTextFile(key: string, url: string) {
if (this.checkKeyExists(key) === false)
{
this._queueSize++;
this._fileList[key] = { type: 'text', key: key, url: url, data: null, error: false, loaded: false };
this._keys.push(key);
}
}
public removeFile(key: string) {
delete this._fileList[key];
}
public removeAll() {
this._fileList = {};
}
public load(onFileLoadCallback = null, onCompleteCallback = null) {
this.progress = 0;
this.hasLoaded = false;
this._onComplete = onCompleteCallback;
if (onCompleteCallback == null)
{
this._onComplete = this._game.onCreateCallback;
}
this._onFileLoad = onFileLoadCallback;
if (this._keys.length > 0)
{
this._progressChunk = 100 / this._keys.length;
this.loadFile();
}
else
{
this.progress = 1;
this.hasLoaded = true;
this._gameCreateComplete.call(this._game);
if (this._onComplete !== null)
{
this._onComplete.call(this._game.callbackContext);
}
}
}
private loadFile() {
var file = this._fileList[this._keys.pop()];
// Image or Data?
switch (file.type)
{
case 'image':
case 'spritesheet':
case 'textureatlas':
file.data = new Image();
file.data.name = file.key;
file.data.onload = () => this.fileComplete(file.key);
file.data.onerror = () => this.fileError(file.key);
file.data.src = file.url;
break;
case 'audio':
this._xhr.open("GET", file.url, true);
this._xhr.responseType = "arraybuffer";
this._xhr.onload = () => this.fileComplete(file.key);
this._xhr.onerror = () => this.fileError(file.key);
this._xhr.send();
break;
case 'text':
this._xhr.open("GET", file.url, true);
this._xhr.responseType = "text";
this._xhr.onload = () => this.fileComplete(file.key);
this._xhr.onerror = () => this.fileError(file.key);
this._xhr.send();
break;
}
}
private fileError(key: string) {
this._fileList[key].loaded = true;
this._fileList[key].error = true;
this.nextFile(key, false);
}
private fileComplete(key: string) {
this._fileList[key].loaded = true;
var file = this._fileList[key];
var loadNext: bool = true;
switch (file.type)
{
case 'image':
this._game.cache.addImage(file.key, file.url, file.data);
break;
case 'spritesheet':
this._game.cache.addSpriteSheet(file.key, file.url, file.data, file.frameWidth, file.frameHeight, file.frameMax);
break;
case 'textureatlas':
if (file.jsonURL == null)
{
this._game.cache.addTextureAtlas(file.key, file.url, file.data, file.jsonData);
}
else
{
// Load the JSON before carrying on with the next file
loadNext = false;
this._xhr.open("GET", file.jsonURL, true);
this._xhr.responseType = "text";
this._xhr.onload = () => this.jsonLoadComplete(file.key);
this._xhr.onerror = () => this.jsonLoadError(file.key);
this._xhr.send();
}
break;
case 'audio':
file.data = this._xhr.response;
this._game.cache.addSound(file.key, file.url, file.data);
break;
case 'text':
file.data = this._xhr.response;
this._game.cache.addText(file.key, file.url, file.data);
break;
}
if (loadNext)
{
this.nextFile(key, true);
}
}
private jsonLoadComplete(key: string) {
var data = JSON.parse(this._xhr.response);
// Malformed?
if (data['frames'])
{
var file = this._fileList[key];
this._game.cache.addTextureAtlas(file.key, file.url, file.data, data['frames']);
}
this.nextFile(key, true);
}
private jsonLoadError(key: string) {
var file = this._fileList[key];
file.error = true;
this.nextFile(key, true);
}
private nextFile(previousKey: string, success: bool) {
this.progress = Math.round(this.progress + this._progressChunk);
if (this.progress > 1)
{
this.progress = 1;
}
if (this._onFileLoad)
{
this._onFileLoad.call(this._game.callbackContext, this.progress, previousKey, success);
}
if (this._keys.length > 0)
{
this.loadFile();
}
else
{
this.hasLoaded = true;
this.removeAll();
this._gameCreateComplete.call(this._game);
if (this._onComplete !== null)
{
this._onComplete.call(this._game.callbackContext);
}
}
}
private checkKeyExists(key: string): bool {
if (this._fileList[key])
{
return true;
}
else
{
return false;
}
}
}
}
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="gameobjects/GameObject.d.ts" />
module Phaser {
class Motion {
constructor(game: Game);
private _game;
public computeVelocity(Velocity: number, Acceleration?: number, Drag?: number, Max?: number): number;
public velocityFromAngle(angle: number, speed: number): Point;
public moveTowardsObject(source: GameObject, dest: GameObject, speed?: number, maxTime?: number): void;
public accelerateTowardsObject(source: GameObject, dest: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
public moveTowardsMouse(source: GameObject, speed?: number, maxTime?: number): void;
public accelerateTowardsMouse(source: GameObject, speed: number, xSpeedMax: number, ySpeedMax: number): void;
public moveTowardsPoint(source: GameObject, target: Point, speed?: number, maxTime?: number): void;
public accelerateTowardsPoint(source: GameObject, target: Point, speed: number, xSpeedMax: number, ySpeedMax: number): void;
public distanceBetween(a: GameObject, b: GameObject): number;
public distanceToPoint(a: GameObject, target: Point): number;
public distanceToMouse(a: GameObject): number;
public angleBetweenPoint(a: GameObject, target: Point, asDegrees?: bool): number;
public angleBetween(a: GameObject, b: GameObject, asDegrees?: bool): number;
public velocityFromFacing(parent: GameObject, speed: number): Point;
public angleBetweenMouse(a: GameObject, asDegrees?: bool): number;
}
}
-409
View File
@@ -1,409 +0,0 @@
/// <reference path="Game.ts" />
/// <reference path="gameobjects/GameObject.ts" />
/**
* Phaser - Motion
*
* The Motion class contains lots of useful functions for moving game objects around in world space.
*/
module Phaser {
export class Motion {
constructor(game: Game) {
this._game = game;
}
private _game: Game;
/**
* A tween-like function that takes a starting velocity and some other factors and returns an altered velocity.
*
* @param Velocity Any component of velocity (e.g. 20).
* @param Acceleration Rate at which the velocity is changing.
* @param Drag Really kind of a deceleration, this is how much the velocity changes if Acceleration is not set.
* @param Max An absolute value cap for the velocity.
*
* @return The altered Velocity value.
*/
public computeVelocity(Velocity: number, Acceleration: number = 0, Drag: number = 0, Max: number = 10000): number {
if (Acceleration !== 0)
{
Velocity += Acceleration * this._game.time.elapsed;
}
else if (Drag !== 0)
{
var drag: number = Drag * this._game.time.elapsed;
if (Velocity - drag > 0)
{
Velocity = Velocity - drag;
}
else if (Velocity + drag < 0)
{
Velocity += drag;
}
else
{
Velocity = 0;
}
}
if ((Velocity != 0) && (Max != 10000))
{
if (Velocity > Max)
{
Velocity = Max;
}
else if (Velocity < -Max)
{
Velocity = -Max;
}
}
return Velocity;
}
/**
* Given the angle and speed calculate the velocity and return it as a Point
*
* @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
* @param speed The speed it will move, in pixels per second sq
*
* @return A Point where Point.x contains the velocity x value and Point.y contains the velocity y value
*/
public velocityFromAngle(angle: number, speed: number): Point {
if (isNaN(speed))
{
speed = 0;
}
var a: number = this._game.math.degreesToRadians(angle);
return new Point((Math.cos(a) * speed), (Math.sin(a) * speed));
}
/**
* Sets the source Sprite x/y velocity so it will move directly towards the destination Sprite at the speed given (in pixels per second)<br>
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
* If you need the object to accelerate, see accelerateTowardsObject() instead
* Note: Doesn't take into account acceleration, maxVelocity or drag (if you set drag or acceleration too high this object may not move at all)
*
* @param source The Sprite on which the velocity will be set
* @param dest The Sprite where the source object will move to
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsObject(source:GameObject, dest:GameObject, speed:number= 60, maxTime:number = 0)
{
var a:number = this.angleBetween(source, dest);
if (maxTime > 0)
{
var d:number = this.distanceBetween(source, dest);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.velocity.x = Math.cos(a) * speed;
source.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the destination Sprite at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsObject() instead.
*
* @param source The Sprite on which the acceleration will be set
* @param dest The Sprite where the source object will move towards
* @param speed The speed it will accelerate in pixels per second
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsObject(source:GameObject, dest:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number)
{
var a:number = this.angleBetween(source, dest);
source.velocity.x = 0;
source.velocity.y = 0;
source.acceleration.x = Math.cos(a) * speed;
source.acceleration.y = Math.sin(a) * speed;
source.maxVelocity.x = xSpeedMax;
source.maxVelocity.y = ySpeedMax;
}
/**
* Move the given Sprite towards the mouse pointer coordinates at a steady velocity
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
*
* @param source The Sprite to move
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsMouse(source:GameObject, speed:number = 60, maxTime:number = 0)
{
var a:number = this.angleBetweenMouse(source);
if (maxTime > 0)
{
var d:number = this.distanceToMouse(source);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.velocity.x = Math.cos(a) * speed;
source.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the mouse coordinates at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsMouse() instead.
*
* @param source The Sprite on which the acceleration will be set
* @param speed The speed it will accelerate in pixels per second
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsMouse(source:GameObject, speed:number, xSpeedMax:number, ySpeedMax:number)
{
var a:number = this.angleBetweenMouse(source);
source.velocity.x = 0;
source.velocity.y = 0;
source.acceleration.x = Math.cos(a) * speed;
source.acceleration.y = Math.sin(a) * speed;
source.maxVelocity.x = xSpeedMax;
source.maxVelocity.y = ySpeedMax;
}
/**
* Sets the x/y velocity on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
* If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.<br>
* Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms.<br>
* The source object doesn't stop moving automatically should it ever reach the destination coordinates.<br>
*
* @param source The Sprite to move
* @param target The Point coordinates to move the source Sprite towards
* @param speed The speed it will move, in pixels per second (default is 60 pixels/sec)
* @param maxTime Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the source will arrive at destination in the given number of ms
*/
public moveTowardsPoint(source:GameObject, target:Point, speed:number = 60, maxTime:number = 0)
{
var a:number = this.angleBetweenPoint(source, target);
if (maxTime > 0)
{
var d:number = this.distanceToPoint(source, target);
// We know how many pixels we need to move, but how fast?
speed = d / (maxTime / 1000);
}
source.velocity.x = Math.cos(a) * speed;
source.velocity.y = Math.sin(a) * speed;
}
/**
* Sets the x/y acceleration on the source Sprite so it will move towards the target coordinates at the speed given (in pixels per second)<br>
* You must give a maximum speed value, beyond which the Sprite won't go any faster.<br>
* If you don't need acceleration look at moveTowardsPoint() instead.
*
* @param source The Sprite on which the acceleration will be set
* @param target The Point coordinates to move the source Sprite towards
* @param speed The speed it will accelerate in pixels per second
* @param xSpeedMax The maximum speed in pixels per second in which the sprite can move horizontally
* @param ySpeedMax The maximum speed in pixels per second in which the sprite can move vertically
*/
public accelerateTowardsPoint(source:GameObject, target:Point, speed:number, xSpeedMax:number, ySpeedMax:number)
{
var a:number = this.angleBetweenPoint(source, target);
source.velocity.x = 0;
source.velocity.y = 0;
source.acceleration.x = Math.cos(a) * speed;
source.acceleration.y = Math.sin(a) * speed;
source.maxVelocity.x = xSpeedMax;
source.maxVelocity.y = ySpeedMax;
}
/**
* Find the distance (in pixels, rounded) between two Sprites, taking their origin into account
*
* @param a The first Sprite
* @param b The second Sprite
* @return int Distance (in pixels)
*/
public distanceBetween(a:GameObject, b:GameObject):number
{
var dx:number = (a.x + a.origin.x) - (b.x + b.origin.x);
var dy:number = (a.y + a.origin.y) - (b.y + b.origin.y);
return this._game.math.vectorLength(dx, dy);
}
/**
* Find the distance (in pixels, rounded) from an Sprite to the given Point, taking the source origin into account
*
* @param a The Sprite
* @param target The Point
* @return int Distance (in pixels)
*/
public distanceToPoint(a:GameObject, target:Point):number
{
var dx:number = (a.x + a.origin.x) - (target.x);
var dy:number = (a.y + a.origin.y) - (target.y);
return this._game.math.vectorLength(dx, dy);
}
/**
* Find the distance (in pixels, rounded) from the object x/y and the mouse x/y
*
* @param a The Sprite to test against
* @return int The distance between the given sprite and the mouse coordinates
*/
public distanceToMouse(a:GameObject):number
{
var dx: number = (a.x + a.origin.x) - this._game.input.x;
var dy: number = (a.y + a.origin.y) - this._game.input.y;
return this._game.math.vectorLength(dx, dy);
}
/**
* Find the angle (in radians) between an Sprite and an Point. The source sprite takes its x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param a The Sprite to test from
* @param target The Point to angle the Sprite towards
* @param asDegrees If you need the value in degrees instead of radians, set to true
*
* @return Number The angle (in radians unless asDegrees is true)
*/
public angleBetweenPoint(a:GameObject, target:Point, asDegrees:bool = false):number
{
var dx:number = (target.x) - (a.x + a.origin.x);
var dy:number = (target.y) - (a.y + a.origin.y);
if (asDegrees)
{
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
/**
* Find the angle (in radians) between the two Sprite, taking their x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param a The Sprite to test from
* @param b The Sprite to test to
* @param asDegrees If you need the value in degrees instead of radians, set to true
*
* @return Number The angle (in radians unless asDegrees is true)
*/
public angleBetween(a:GameObject, b:GameObject, asDegrees:bool = false):number
{
var dx:number = (b.x + b.origin.x) - (a.x + a.origin.x);
var dy:number = (b.y + b.origin.y) - (a.y + a.origin.y);
if (asDegrees)
{
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
/**
* Given the GameObject and speed calculate the velocity and return it as an Point based on the direction the sprite is facing
*
* @param parent The Sprite to get the facing value from
* @param speed The speed it will move, in pixels per second sq
*
* @return An Point where Point.x contains the velocity x value and Point.y contains the velocity y value
*/
public velocityFromFacing(parent:GameObject, speed:number):Point
{
var a:number;
if (parent.facing == Collision.LEFT)
{
a = this._game.math.degreesToRadians(180);
}
else if (parent.facing == Collision.RIGHT)
{
a = this._game.math.degreesToRadians(0);
}
else if (parent.facing == Collision.UP)
{
a = this._game.math.degreesToRadians(-90);
}
else if (parent.facing == Collision.DOWN)
{
a = this._game.math.degreesToRadians(90);
}
return new Point(Math.cos(a) * speed, Math.sin(a) * speed);
}
/**
* Find the angle (in radians) between an Sprite and the mouse, taking their x/y and origin into account.
* The angle is calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)
*
* @param a The Object to test from
* @param asDegrees If you need the value in degrees instead of radians, set to true
*
* @return Number The angle (in radians unless asDegrees is true)
*/
public angleBetweenMouse(a:GameObject, asDegrees:bool = false):number
{
// In order to get the angle between the object and mouse, we need the objects screen coordinates (rather than world coordinates)
var p:MicroPoint = a.getScreenXY();
var dx:number = a._game.input.x - p.x;
var dy:number = a._game.input.y - p.y;
if (asDegrees)
{
return this._game.math.radiansToDegrees(Math.atan2(dy, dx));
}
else
{
return Math.atan2(dy, dx);
}
}
}
}
-345
View File
@@ -1,345 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<ProjectGuid>{A90BE60F-CAEA-4747-904A-CDB097BA2459}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<OutputPath>bin</OutputPath>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>Phaser</RootNamespace>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:51891/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>true</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TypeScriptTarget>ES5</TypeScriptTarget>
<TypeScriptIncludeComments>false</TypeScriptIncludeComments>
<TypeScriptSourceMap>false</TypeScriptSourceMap>
<TypeScriptOutFile>../build/phaser.js</TypeScriptOutFile>
<TypeScriptGeneratesDeclarations>true</TypeScriptGeneratesDeclarations>
</PropertyGroup>
<ItemGroup>
<Folder Include="plugins\" />
</ItemGroup>
<ItemGroup>
<Content Include="AnimationManager.js">
<DependentUpon>AnimationManager.ts</DependentUpon>
</Content>
<Content Include="Collision.js">
<DependentUpon>Collision.ts</DependentUpon>
</Content>
<Content Include="DynamicTexture.js">
<DependentUpon>DynamicTexture.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="FXManager.ts" />
<Content Include="FXManager.js">
<DependentUpon>FXManager.ts</DependentUpon>
</Content>
<Content Include="Game.js">
<DependentUpon>Game.ts</DependentUpon>
</Content>
<Content Include="GameMath.js">
<DependentUpon>GameMath.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Emitter.js">
<DependentUpon>Emitter.ts</DependentUpon>
</Content>
<Content Include="gameobjects\GameObject.js">
<DependentUpon>GameObject.ts</DependentUpon>
</Content>
<Content Include="gameobjects\GeomSprite.js">
<DependentUpon>GeomSprite.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Particle.js">
<DependentUpon>Particle.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="gameobjects\ScrollZone.ts" />
<TypeScriptCompile Include="gameobjects\ScrollRegion.ts" />
<Content Include="gameobjects\ScrollRegion.js">
<DependentUpon>ScrollRegion.ts</DependentUpon>
</Content>
<Content Include="gameobjects\ScrollZone.js">
<DependentUpon>ScrollZone.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Sprite.js">
<DependentUpon>Sprite.ts</DependentUpon>
</Content>
<Content Include="gameobjects\Tilemap.js">
<DependentUpon>Tilemap.ts</DependentUpon>
</Content>
<Content Include="geom\Circle.js">
<DependentUpon>Circle.ts</DependentUpon>
</Content>
<Content Include="geom\IntersectResult.js">
<DependentUpon>IntersectResult.ts</DependentUpon>
</Content>
<Content Include="geom\Line.js">
<DependentUpon>Line.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="geom\MicroPoint.ts" />
<Content Include="geom\MicroPoint.js">
<DependentUpon>MicroPoint.ts</DependentUpon>
</Content>
<Content Include="geom\Point.js">
<DependentUpon>Point.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="geom\Quad.ts" />
<Content Include="geom\Quad.js">
<DependentUpon>Quad.ts</DependentUpon>
</Content>
<Content Include="geom\Rectangle.js">
<DependentUpon>Rectangle.ts</DependentUpon>
</Content>
<Content Include="SoundManager.js">
<DependentUpon>SoundManager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\screens\PauseScreen.ts" />
<TypeScriptCompile Include="system\screens\BootScreen.ts" />
<Content Include="system\screens\BootScreen.js">
<DependentUpon>BootScreen.ts</DependentUpon>
</Content>
<Content Include="system\screens\PauseScreen.js">
<DependentUpon>PauseScreen.ts</DependentUpon>
</Content>
<Content Include="system\Sound.js">
<DependentUpon>Sound.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\Sound.ts" />
<TypeScriptCompile Include="SoundManager.ts" />
<Content Include="system\animation\Animation.js">
<DependentUpon>Animation.ts</DependentUpon>
</Content>
<Content Include="system\animation\AnimationLoader.js">
<DependentUpon>AnimationLoader.ts</DependentUpon>
</Content>
<Content Include="system\animation\Frame.js">
<DependentUpon>Frame.ts</DependentUpon>
</Content>
<Content Include="system\animation\FrameData.js">
<DependentUpon>FrameData.ts</DependentUpon>
</Content>
<Content Include="system\Camera.js">
<DependentUpon>Camera.ts</DependentUpon>
</Content>
<Content Include="system\Device.js">
<DependentUpon>Device.ts</DependentUpon>
</Content>
<Content Include="system\LinkedList.js">
<DependentUpon>LinkedList.ts</DependentUpon>
</Content>
<Content Include="system\QuadTree.js">
<DependentUpon>QuadTree.ts</DependentUpon>
</Content>
<Content Include="system\RandomDataGenerator.js">
<DependentUpon>RandomDataGenerator.ts</DependentUpon>
</Content>
<Content Include="system\RequestAnimationFrame.js">
<DependentUpon>RequestAnimationFrame.ts</DependentUpon>
</Content>
<Content Include="system\StageScaleMode.js">
<DependentUpon>StageScaleMode.ts</DependentUpon>
</Content>
<Content Include="system\Tile.js">
<DependentUpon>Tile.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\TilemapLayer.ts" />
<Content Include="system\TilemapLayer.js">
<DependentUpon>TilemapLayer.ts</DependentUpon>
</Content>
<Content Include="system\Tween.js">
<DependentUpon>Tween.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\Tween.ts" />
<TypeScriptCompile Include="system\Tile.ts" />
<TypeScriptCompile Include="system\StageScaleMode.ts" />
<TypeScriptCompile Include="system\RequestAnimationFrame.ts" />
<TypeScriptCompile Include="system\RandomDataGenerator.ts" />
<TypeScriptCompile Include="system\QuadTree.ts" />
<TypeScriptCompile Include="system\LinkedList.ts" />
<TypeScriptCompile Include="system\Device.ts" />
<TypeScriptCompile Include="system\Camera.ts" />
<Content Include="system\easing\Back.js">
<DependentUpon>Back.ts</DependentUpon>
</Content>
<Content Include="system\easing\Bounce.js">
<DependentUpon>Bounce.ts</DependentUpon>
</Content>
<Content Include="system\easing\Circular.js">
<DependentUpon>Circular.ts</DependentUpon>
</Content>
<Content Include="system\easing\Cubic.js">
<DependentUpon>Cubic.ts</DependentUpon>
</Content>
<Content Include="system\easing\Elastic.js">
<DependentUpon>Elastic.ts</DependentUpon>
</Content>
<Content Include="system\easing\Exponential.js">
<DependentUpon>Exponential.ts</DependentUpon>
</Content>
<Content Include="system\easing\Linear.js">
<DependentUpon>Linear.ts</DependentUpon>
</Content>
<Content Include="system\easing\Quadratic.js">
<DependentUpon>Quadratic.ts</DependentUpon>
</Content>
<Content Include="system\easing\Quartic.js">
<DependentUpon>Quartic.ts</DependentUpon>
</Content>
<Content Include="system\easing\Quintic.js">
<DependentUpon>Quintic.ts</DependentUpon>
</Content>
<Content Include="system\easing\Sinusoidal.js">
<DependentUpon>Sinusoidal.ts</DependentUpon>
</Content>
<Content Include="system\input\Finger.js">
<DependentUpon>Finger.ts</DependentUpon>
</Content>
<Content Include="system\input\Input.js">
<DependentUpon>Input.ts</DependentUpon>
</Content>
<Content Include="system\input\Keyboard.js">
<DependentUpon>Keyboard.ts</DependentUpon>
</Content>
<Content Include="system\input\Mouse.js">
<DependentUpon>Mouse.ts</DependentUpon>
</Content>
<Content Include="system\input\Touch.js">
<DependentUpon>Touch.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="system\input\Touch.ts" />
<TypeScriptCompile Include="system\input\Mouse.ts" />
<TypeScriptCompile Include="system\input\Keyboard.ts" />
<TypeScriptCompile Include="system\input\Input.ts" />
<TypeScriptCompile Include="system\input\Finger.ts" />
<TypeScriptCompile Include="system\easing\Sinusoidal.ts" />
<TypeScriptCompile Include="system\easing\Quintic.ts" />
<TypeScriptCompile Include="system\easing\Quartic.ts" />
<TypeScriptCompile Include="system\easing\Quadratic.ts" />
<TypeScriptCompile Include="system\easing\Linear.ts" />
<TypeScriptCompile Include="system\easing\Exponential.ts" />
<TypeScriptCompile Include="system\easing\Elastic.ts" />
<TypeScriptCompile Include="system\easing\Cubic.ts" />
<TypeScriptCompile Include="system\easing\Circular.ts" />
<TypeScriptCompile Include="system\easing\Bounce.ts" />
<TypeScriptCompile Include="system\easing\Back.ts" />
<TypeScriptCompile Include="system\animation\FrameData.ts" />
<TypeScriptCompile Include="system\animation\Frame.ts" />
<TypeScriptCompile Include="system\animation\AnimationLoader.ts" />
<TypeScriptCompile Include="system\animation\Animation.ts" />
<TypeScriptCompile Include="geom\Rectangle.ts" />
<TypeScriptCompile Include="geom\Point.ts" />
<TypeScriptCompile Include="geom\Line.ts" />
<TypeScriptCompile Include="geom\IntersectResult.ts" />
<TypeScriptCompile Include="geom\Circle.ts" />
<TypeScriptCompile Include="gameobjects\Tilemap.ts" />
<TypeScriptCompile Include="gameobjects\Sprite.ts" />
<TypeScriptCompile Include="gameobjects\Particle.ts" />
<TypeScriptCompile Include="gameobjects\GeomSprite.ts" />
<TypeScriptCompile Include="gameobjects\GameObject.ts" />
<TypeScriptCompile Include="gameobjects\Emitter.ts" />
<Content Include="Group.js">
<DependentUpon>Group.ts</DependentUpon>
</Content>
<Content Include="Loader.js">
<DependentUpon>Loader.ts</DependentUpon>
</Content>
<Content Include="Motion.js">
<DependentUpon>Motion.ts</DependentUpon>
</Content>
<Content Include="Phaser.js">
<DependentUpon>Phaser.ts</DependentUpon>
</Content>
<Content Include="Signal.js">
<DependentUpon>Signal.ts</DependentUpon>
</Content>
<Content Include="SignalBinding.js">
<DependentUpon>SignalBinding.ts</DependentUpon>
</Content>
<Content Include="Stage.js">
<DependentUpon>Stage.ts</DependentUpon>
</Content>
<Content Include="State.js">
<DependentUpon>State.ts</DependentUpon>
</Content>
<Content Include="Time.js">
<DependentUpon>Time.ts</DependentUpon>
</Content>
<Content Include="TweenManager.js">
<DependentUpon>TweenManager.ts</DependentUpon>
</Content>
<Content Include="World.js">
<DependentUpon>World.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="World.ts" />
<TypeScriptCompile Include="TweenManager.ts" />
<TypeScriptCompile Include="Time.ts" />
<TypeScriptCompile Include="State.ts" />
<TypeScriptCompile Include="Stage.ts" />
<TypeScriptCompile Include="SignalBinding.ts" />
<TypeScriptCompile Include="Signal.ts" />
<TypeScriptCompile Include="Phaser.ts" />
<TypeScriptCompile Include="Motion.ts" />
<TypeScriptCompile Include="Loader.ts" />
<TypeScriptCompile Include="Group.ts" />
<TypeScriptCompile Include="GameMath.ts" />
<TypeScriptCompile Include="Game.ts" />
<TypeScriptCompile Include="DynamicTexture.ts" />
<TypeScriptCompile Include="Collision.ts" />
<TypeScriptCompile Include="AnimationManager.ts" />
<Content Include="Basic.js">
<DependentUpon>Basic.ts</DependentUpon>
</Content>
<Content Include="Cache.js">
<DependentUpon>Cache.ts</DependentUpon>
</Content>
<Content Include="CameraManager.js">
<DependentUpon>CameraManager.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="CameraManager.ts" />
<TypeScriptCompile Include="Cache.ts" />
<TypeScriptCompile Include="Basic.ts" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TypeScript\Microsoft.TypeScript.targets" />
<PropertyGroup>
<PostBuildEvent>cd $(ProjectDir)..\build
copy phaser.js ..\Tests\</PostBuildEvent>
</PropertyGroup>
</Project>
-3
View File
@@ -1,3 +0,0 @@
module Phaser {
var VERSION: string;
}
-21
View File
@@ -1,21 +0,0 @@
/**
* Phaser
*
* v0.9.5 - April 28th 2013
*
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
*
* Richard Davey (@photonstorm)
*
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel on which Phaser took a lot of inspiration.
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
* -- Albert Einstein
*/
module Phaser {
export var VERSION: string = 'Phaser version 0.9.5';
}
-26
View File
@@ -1,26 +0,0 @@
/// <reference path="SignalBinding.d.ts" />
module Phaser {
class Signal {
private _bindings;
private _prevParams;
static VERSION: string;
public memorize: bool;
private _shouldPropagate;
public active: bool;
public validateListener(listener, fnName): void;
private _registerListener(listener, isOnce, listenerContext, priority);
private _addBinding(binding);
private _indexOfListener(listener, context);
public has(listener, context?: any): bool;
public add(listener, listenerContext?: any, priority?: number): SignalBinding;
public addOnce(listener, listenerContext?: any, priority?: number): SignalBinding;
public remove(listener, context?: any);
public removeAll(): void;
public getNumListeners(): number;
public halt(): void;
public dispatch(...paramsArr: any[]): void;
public forget(): void;
public dispose(): void;
public toString(): string;
}
}
-21
View File
@@ -1,21 +0,0 @@
/// <reference path="Signal.d.ts" />
module Phaser {
class SignalBinding {
constructor(signal: Signal, listener, isOnce: bool, listenerContext, priority?: number);
private _listener;
private _isOnce;
public context;
private _signal;
public priority: number;
public active: bool;
public params;
public execute(paramsArr?: any[]);
public detach();
public isBound(): bool;
public isOnce(): bool;
public getListener();
public getSignal(): Signal;
public _destroy(): void;
public toString(): string;
}
}
-16
View File
@@ -1,16 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="system/Sound.d.ts" />
module Phaser {
class SoundManager {
constructor(game: Game);
private _game;
private _context;
private _gainNode;
private _volume;
public mute(): void;
public unmute(): void;
public volume : number;
public decode(key: string, callback?, sound?: Sound): void;
public play(key: string, volume?: number, loop?: bool): Sound;
}
}
-124
View File
@@ -1,124 +0,0 @@
/// <reference path="Game.ts" />
/// <reference path="system/Sound.ts" />
/**
* Phaser - SoundManager
*
* This is an embroyonic web audio sound management class. There is a lot of work still to do here.
*/
module Phaser {
export class SoundManager {
constructor(game: Game) {
this._game = game;
if (game.device.webaudio == true)
{
if (!!window['AudioContext'])
{
this._context = new window['AudioContext']();
}
else if (!!window['webkitAudioContext'])
{
this._context = new window['webkitAudioContext']();
}
if (this._context !== null)
{
this._gainNode = this._context.createGainNode();
this._gainNode.connect(this._context.destination);
this._volume = 1;
}
}
}
private _game: Game;
private _context = null;
private _gainNode;
private _volume: number;
public mute() {
this._gainNode.gain.value = 0;
}
public unmute() {
this._gainNode.gain.value = this._volume;
}
public set volume(value: number) {
this._volume = value;
this._gainNode.gain.value = this._volume;
}
public get volume(): number {
return this._volume;
}
public decode(key: string, callback = null, sound?: Sound = null) {
var soundData = this._game.cache.getSound(key);
if (soundData)
{
if (this._game.cache.isSoundDecoded(key) === false)
{
var that = this;
this._context.decodeAudioData(soundData, function (buffer) {
that._game.cache.decodedSound(key, buffer);
if (sound)
{
sound.setDecodedBuffer(buffer);
}
callback();
});
}
}
}
public play(key: string, volume?: number = 1, loop?: bool = false): Sound {
if (this._context === null)
{
return;
}
var soundData = this._game.cache.getSound(key);
if (soundData)
{
// Does the sound need decoding?
if (this._game.cache.isSoundDecoded(key) === true)
{
return new Sound(this._context, this._gainNode, soundData, volume, loop);
}
else
{
var tempSound: Sound = new Sound(this._context, this._gainNode, null, volume, loop);
// this is an async process, so we can return the Sound object anyway, it just won't be playing yet
this.decode(key, () => tempSound.play(), tempSound);
return tempSound;
}
}
}
}
}
-47
View File
@@ -1,47 +0,0 @@
/// <reference path="Phaser.d.ts" />
/// <reference path="Game.d.ts" />
/// <reference path="system/StageScaleMode.d.ts" />
/// <reference path="system/screens/BootScreen.d.ts" />
/// <reference path="system/screens/PauseScreen.d.ts" />
module Phaser {
class Stage {
constructor(game: Game, parent: string, width: number, height: number);
private _game;
private _bgColor;
private _bootScreen;
private _pauseScreen;
static ORIENTATION_LANDSCAPE: number;
static ORIENTATION_PORTRAIT: number;
public bounds: Rectangle;
public aspectRatio: number;
public clear: bool;
public canvas: HTMLCanvasElement;
public context: CanvasRenderingContext2D;
public disablePauseScreen: bool;
public disableBootScreen: bool;
public offset: Point;
public scale: StageScaleMode;
public scaleMode: number;
public minScaleX: number;
public maxScaleX: number;
public minScaleY: number;
public maxScaleY: number;
public update(): void;
private visibilityChange(event);
private getOffset(element);
public strokeStyle: string;
public lineWidth: number;
public fillStyle: string;
public saveCanvasValues(): void;
public restoreCanvasValues(): void;
public backgroundColor : string;
public x : number;
public y : number;
public width : number;
public height : number;
public centerX : number;
public centerY : number;
public randomX : number;
public randomY : number;
}
}
-209
View File
@@ -1,209 +0,0 @@
/// <reference path="Phaser.ts" />
/// <reference path="Game.ts" />
/// <reference path="system/StageScaleMode.ts" />
/// <reference path="system/screens/BootScreen.ts" />
/// <reference path="system/screens/PauseScreen.ts" />
/**
* Phaser - Stage
*
* The Stage is the canvas on which everything is displayed. This class handles display within the web browser, focus handling,
* resizing, scaling and pause/boot screens.
*/
module Phaser {
export class Stage {
constructor(game: Game, parent: string, width: number, height: number) {
this._game = game;
this.canvas = <HTMLCanvasElement> document.createElement('canvas');
this.canvas.width = width;
this.canvas.height = height;
if (document.getElementById(parent))
{
document.getElementById(parent).appendChild(this.canvas);
document.getElementById(parent).style.overflow = 'hidden';
}
else
{
document.body.appendChild(this.canvas);
}
// Consume default actions on the canvas
this.canvas.style.msTouchAction = 'none';
this.canvas.style['touch-action'] = 'none';
this.context = this.canvas.getContext('2d');
this.offset = this.getOffset(this.canvas);
this.bounds = new Rectangle(this.offset.x, this.offset.y, width, height);
this.aspectRatio = width / height;
this.scaleMode = StageScaleMode.NO_SCALE;
this.scale = new StageScaleMode(this._game);
this._bootScreen = new BootScreen(this._game);
this._pauseScreen = new PauseScreen(this._game, width, height);
document.addEventListener('visibilitychange', (event) => this.visibilityChange(event), false);
document.addEventListener('webkitvisibilitychange', (event) => this.visibilityChange(event), false);
window.onblur = (event) => this.visibilityChange(event);
window.onfocus = (event) => this.visibilityChange(event);
}
private _game: Game;
private _bgColor: string;
private _bootScreen;
private _pauseScreen;
public static ORIENTATION_LANDSCAPE: number = 0;
public static ORIENTATION_PORTRAIT: number = 1;
public bounds: Rectangle;
public aspectRatio: number;
public clear: bool = true;
public canvas: HTMLCanvasElement;
public context: CanvasRenderingContext2D;
public disablePauseScreen: bool = false;
public disableBootScreen: bool = false;
public offset: Point;
public scale: StageScaleMode;
public scaleMode: number;
public minScaleX: number = null;
public maxScaleX: number = null;
public minScaleY: number = null;
public maxScaleY: number = null;
public update() {
this.scale.update();
if (this.clear)
{
// implement dirty rect? could take up more cpu time than it saves. needs benching.
this.context.clearRect(0, 0, this.width, this.height);
}
if (this._game.isRunning == false && this.disableBootScreen == false)
{
this._bootScreen.update();
this._bootScreen.render();
}
if (this._game.paused == true && this.disablePauseScreen == false)
{
this._pauseScreen.update();
this._pauseScreen.render();
}
}
private visibilityChange(event) {
if (this.disablePauseScreen)
{
return;
}
if (event.type === 'blur' || document['hidden'] === true || document['webkitHidden'] === true)
{
if (this._game.paused == false)
{
this._pauseScreen.onPaused();
this.saveCanvasValues();
this._game.paused = true;
}
}
else if (event.type == 'focus')
{
if (this._game.paused == true)
{
this._pauseScreen.onResume();
this._game.paused = false;
this.restoreCanvasValues();
}
}
}
private getOffset(element): Point {
var box = element.getBoundingClientRect();
var clientTop = element.clientTop || document.body.clientTop || 0;
var clientLeft = element.clientLeft || document.body.clientLeft || 0;
var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop;
var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft;
return new Point(box.left + scrollLeft - clientLeft, box.top + scrollTop - clientTop);
}
public strokeStyle: string;
public lineWidth: number;
public fillStyle: string;
public saveCanvasValues() {
this.strokeStyle = this.context.strokeStyle;
this.lineWidth = this.context.lineWidth;
this.fillStyle = this.context.fillStyle;
}
public restoreCanvasValues() {
this.context.strokeStyle = this.strokeStyle;
this.context.lineWidth = this.lineWidth;
this.context.fillStyle = this.fillStyle;
}
public set backgroundColor(color: string) {
this.canvas.style.backgroundColor = color;
}
public get backgroundColor(): string {
return this._bgColor;
}
public get x(): number {
return this.bounds.x;
}
public get y(): number {
return this.bounds.y;
}
public get width(): number {
return this.bounds.width;
}
public get height(): number {
return this.bounds.height;
}
public get centerX(): number {
return this.bounds.halfWidth;
}
public get centerY(): number {
return this.bounds.halfHeight;
}
public get randomX(): number {
return Math.round(Math.random() * this.bounds.width);
}
public get randomY(): number {
return Math.round(Math.random() * this.bounds.height);
}
}
}
-103
View File
@@ -1,103 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - State
*
* This is a base State class which can be extended if you are creating your game using TypeScript.
*/
module Phaser {
export class State {
constructor(game: Game) {
this.game = game;
this.camera = game.camera;
this.cache = game.cache;
this.collision = game.collision;
this.input = game.input;
this.loader = game.loader;
this.math = game.math;
this.motion = game.motion;
this.sound = game.sound;
this.stage = game.stage;
this.time = game.time;
this.tweens = game.tweens;
this.world = game.world;
}
public game: Game;
public camera: Camera;
public cache: Cache;
public collision: Collision;
public input: Input;
public loader: Loader;
public math: GameMath;
public motion: Motion;
public sound: SoundManager;
public stage: Stage;
public time: Time;
public tweens: TweenManager;
public world: World;
// Overload these in your own States
public init() { }
public create() { }
public update() { }
public render() { }
public paused() { }
// Handy Proxy methods
public createCamera(x: number, y: number, width: number, height: number): Camera {
return this.game.world.createCamera(x, y, width, height);
}
public createGeomSprite(x: number, y: number): GeomSprite {
return this.world.createGeomSprite(x, y);
}
public createSprite(x: number, y: number, key?: string = ''): Sprite {
return this.game.world.createSprite(x, y, key);
}
public createDynamicTexture(width: number, height: number): DynamicTexture {
return this.game.world.createDynamicTexture(width, height);
}
public createGroup(MaxSize?: number = 0): Group {
return this.game.world.createGroup(MaxSize);
}
public createParticle(): Particle {
return this.game.world.createParticle();
}
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
return this.game.world.createEmitter(x, y, size);
}
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return this.game.world.createScrollZone(key, x, y, width, height);
}
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
return this.game.world.createTilemap(key, mapData, format, resizeWorld, tileWidth, tileHeight);
}
public createTween(obj): Tween {
return this.game.tweens.create(obj);
}
public collide(ObjectOrGroup1: Basic = null, ObjectOrGroup2: Basic = null, NotifyCallback = null): bool {
return this.collision.overlap(ObjectOrGroup1, ObjectOrGroup2, NotifyCallback, Collision.separate);
}
}
}
-25
View File
@@ -1,25 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class Time {
constructor(game: Game);
private _game;
private _started;
public timeScale: number;
public elapsed: number;
public time: number;
public now: number;
public delta: number;
public totalElapsedSeconds : number;
public fps: number;
public fpsMin: number;
public fpsMax: number;
public msMin: number;
public msMax: number;
public frames: number;
private _timeLastSecond;
public update(): void;
public elapsedSince(since: number): number;
public elapsedSecondsSince(since: number): number;
public reset(): void;
}
}
-140
View File
@@ -1,140 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - Time
*
* This is the game clock and it manages elapsed time and calculation of delta values, used for game object motion.
*/
module Phaser {
export class Time {
constructor(game: Game) {
this._started = Date.now();
this._timeLastSecond = this._started;
this.time = this._started;
}
private _game: Game;
private _started: number;
public timeScale: number = 1.0;
public elapsed: number = 0;
/**
*
* @property time
* @type Number
*/
public time: number = 0;
/**
*
* @property now
* @type Number
*/
public now: number = 0;
/**
*
* @property delta
* @type Number
*/
public delta: number = 0;
/**
*
* @method totalElapsedSeconds
* @return {Number}
*/
public get totalElapsedSeconds(): number {
return (this.now - this._started) * 0.001;
}
public fps: number = 0;
public fpsMin: number = 1000;
public fpsMax: number = 0;
public msMin: number = 1000;
public msMax: number = 0;
public frames: number = 0;
private _timeLastSecond: number = 0;
/**
*
* @method update
*/
public update() {
// Can we use performance.now() ?
this.now = Date.now(); // mark
this.delta = this.now - this.time; // elapsedMS
this.msMin = Math.min(this.msMin, this.delta);
this.msMax = Math.max(this.msMax, this.delta);
this.frames++;
if (this.now > this._timeLastSecond + 1000)
{
this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond));
this.fpsMin = Math.min(this.fpsMin, this.fps);
this.fpsMax = Math.max(this.fpsMax, this.fps);
this._timeLastSecond = this.now;
this.frames = 0;
}
this.time = this.now; // _total
//// Lock the delta at 0.1 to minimise fps tunneling
//if (this.delta > 0.1)
//{
// this.delta = 0.1;
//}
}
/**
*
* @method elapsedSince
* @param {Number} since
* @return {Number}
*/
public elapsedSince(since: number): number {
return this.now - since;
}
/**
*
* @method elapsedSecondsSince
* @param {Number} since
* @return {Number}
*/
public elapsedSecondsSince(since: number): number {
return (this.now - since) * 0.001;
}
/**
*
* @method reset
*/
public reset() {
this._started = this.now;
}
}
}
-15
View File
@@ -1,15 +0,0 @@
/// <reference path="Game.d.ts" />
/// <reference path="system/Tween.d.ts" />
module Phaser {
class TweenManager {
constructor(game: Game);
private _game;
private _tweens;
public getAll(): Tween[];
public removeAll(): void;
public create(object): Tween;
public add(tween: Tween): Tween;
public remove(tween: Tween): void;
public update(): bool;
}
}
-95
View File
@@ -1,95 +0,0 @@
/// <reference path="Game.ts" />
/// <reference path="system/Tween.ts" />
/**
* Phaser - TweenManager
*
* The Game has a single instance of the TweenManager through which all Tween objects are created and updated.
* Tweens are hooked into the game clock and pause system, adjusting based on the game state.
* TweenManager is based heavily on tween.js by sole (http://soledadpenades.com).
* I converted it to TypeScript, swapped the callbacks for signals and patched a few issues with regard
* to properties and completion errors. Please see https://github.com/sole/tween.js for a full list of contributors.
*/
module Phaser {
export class TweenManager {
constructor(game: Phaser.Game) {
this._game = game;
this._tweens = [];
}
private _game: Phaser.Game;
private _tweens: Phaser.Tween[];
public getAll() {
return this._tweens;
}
public removeAll() {
this._tweens.length = 0;
}
public create(object): Phaser.Tween {
return new Phaser.Tween(object, this._game);
}
public add(tween: Phaser.Tween) {
tween.parent = this._game;
this._tweens.push(tween);
return tween;
}
public remove(tween: Phaser.Tween) {
var i = this._tweens.indexOf(tween);
if (i !== -1)
{
this._tweens.splice(i, 1);
}
}
public update() {
if (this._tweens.length === 0)
{
return false;
}
var i = 0;
var numTweens = this._tweens.length;
while (i < numTweens)
{
if (this._tweens[i].update(this._game.time.now))
{
i++;
}
else
{
this._tweens.splice(i, 1);
numTweens--;
}
}
return true;
}
}
}
-32
View File
@@ -1,32 +0,0 @@
/// <reference path="Game.d.ts" />
module Phaser {
class World {
constructor(game: Game, width: number, height: number);
private _game;
public cameras: CameraManager;
public group: Group;
public bounds: Rectangle;
public worldDivisions: number;
public update(): void;
public render(): void;
public destroy(): void;
public setSize(width: number, height: number, updateCameraBounds?: bool): void;
public width : number;
public height : number;
public centerX : number;
public centerY : number;
public randomX : number;
public randomY : number;
public createCamera(x: number, y: number, width: number, height: number): Camera;
public removeCamera(id: number): bool;
public getAllCameras(): Camera[];
public createSprite(x: number, y: number, key?: string): Sprite;
public createGeomSprite(x: number, y: number): GeomSprite;
public createDynamicTexture(width: number, height: number): DynamicTexture;
public createGroup(MaxSize?: number): Group;
public createScrollZone(key: string, x?: number, y?: number, width?: number, height?: number): ScrollZone;
public createTilemap(key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number): Tilemap;
public createParticle(): Particle;
public createEmitter(x?: number, y?: number, size?: number): Emitter;
}
}
-159
View File
@@ -1,159 +0,0 @@
/// <reference path="Game.ts" />
/**
* Phaser - World
*
* A game has only one world. The world is an abstract place in which all game objects live. It is not bound
* by stage limits and can be any size or dimension. You look into the world via cameras and all game objects
* live within the world at world-based coordinates. By default a world is created the same size as your Stage.
*/
module Phaser {
export class World {
constructor(game: Game, width: number, height: number) {
this._game = game;
this.cameras = new CameraManager(this._game, 0, 0, width, height);
this._game.camera = this.cameras.current;
this.group = new Group(this._game, 0);
this.bounds = new Rectangle(0, 0, width, height);
this.worldDivisions = 6;
}
private _game: Game;
public cameras: CameraManager;
public group: Group;
public bounds: Rectangle;
public worldDivisions: number;
public update() {
this.group.preUpdate();
this.group.update();
this.group.postUpdate();
this.cameras.update();
}
public render() {
// Unlike in flixel our render process is camera driven, not group driven
this.cameras.render();
}
public destroy() {
this.group.destroy();
this.cameras.destroy();
}
// World methods
public setSize(width: number, height: number, updateCameraBounds: bool = true) {
this.bounds.width = width;
this.bounds.height = height;
if (updateCameraBounds == true)
{
this._game.camera.setBounds(0, 0, width, height);
}
}
public get width(): number {
return this.bounds.width;
}
public set width(value: number) {
this.bounds.width = value;
}
public get height(): number {
return this.bounds.height;
}
public set height(value: number) {
this.bounds.height = value;
}
public get centerX(): number {
return this.bounds.halfWidth;
}
public get centerY(): number {
return this.bounds.halfHeight;
}
public get randomX(): number {
return Math.round(Math.random() * this.bounds.width);
}
public get randomY(): number {
return Math.round(Math.random() * this.bounds.height);
}
// Cameras
public createCamera(x: number, y: number, width: number, height: number): Camera {
return this.cameras.addCamera(x, y, width, height);
}
public removeCamera(id: number): bool {
return this.cameras.removeCamera(id);
}
public getAllCameras(): Camera[] {
return this.cameras.getAll();
}
// Game Objects
public createSprite(x: number, y: number, key?: string = ''): Sprite {
return <Sprite> this.group.add(new Sprite(this._game, x, y, key));
}
public createGeomSprite(x: number, y: number): GeomSprite {
return <GeomSprite> this.group.add(new GeomSprite(this._game, x, y));
}
public createDynamicTexture(width: number, height: number): DynamicTexture {
return new DynamicTexture(this._game, width, height);
}
public createGroup(MaxSize?: number = 0): Group {
return <Group> this.group.add(new Group(this._game, MaxSize));
}
public createScrollZone(key: string, x?: number = 0, y?: number = 0, width?: number = 0, height?: number = 0): ScrollZone {
return <ScrollZone> this.group.add(new ScrollZone(this._game, key, x, y, width, height));
}
public createTilemap(key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0): Tilemap {
return <Tilemap> this.group.add(new Tilemap(this._game, key, mapData, format, resizeWorld, tileWidth, tileHeight));
}
public createParticle(): Particle {
return new Particle(this._game);
}
public createEmitter(x?: number = 0, y?: number = 0, size?: number = 0): Emitter {
return <Emitter> this.group.add(new Emitter(this._game, x, y, size));
}
}
}
-38
View File
@@ -1,38 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../Group.d.ts" />
module Phaser {
class Emitter extends Group {
constructor(game: Game, X?: number, Y?: number, Size?: number);
public x: number;
public y: number;
public width: number;
public height: number;
public minParticleSpeed: MicroPoint;
public maxParticleSpeed: MicroPoint;
public particleDrag: MicroPoint;
public minRotation: number;
public maxRotation: number;
public gravity: number;
public on: bool;
public frequency: number;
public lifespan: number;
public bounce: number;
public particleClass;
private _quantity;
private _explode;
private _timer;
private _counter;
private _point;
public destroy(): void;
public makeParticles(Graphics, Quantity?: number, BakedRotations?: number, Multiple?: bool, Collide?: number): Emitter;
public update(): void;
public kill(): void;
public start(Explode?: bool, Lifespan?: number, Frequency?: number, Quantity?: number): void;
public emitParticle(): void;
public setSize(Width: number, Height: number): void;
public setXSpeed(Min?: number, Max?: number): void;
public setYSpeed(Min?: number, Max?: number): void;
public setRotation(Min?: number, Max?: number): void;
public at(Object): void;
}
}
-452
View File
@@ -1,452 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../Group.ts" />
/**
* Phaser - Emitter
*
* Emitter is a lightweight particle emitter. It can be used for one-time explosions or for
* continuous effects like rain and fire. All it really does is launch Particle objects out
* at set intervals, and fixes their positions and velocities accorindgly.
*/
module Phaser {
export class Emitter extends Group {
/**
* Creates a new <code>Emitter</code> object at a specific position.
* Does NOT automatically generate or attach particles!
*
* @param X The X position of the emitter.
* @param Y The Y position of the emitter.
* @param Size Optional, specifies a maximum capacity for this emitter.
*/
constructor(game: Game, X: number = 0, Y: number = 0, Size: number = 0) {
super(game, Size);
this.x = X;
this.y = Y;
this.width = 0;
this.height = 0;
this.minParticleSpeed = new MicroPoint(-100, -100);
this.maxParticleSpeed = new MicroPoint(100, 100);
this.minRotation = -360;
this.maxRotation = 360;
this.gravity = 0;
this.particleClass = null;
this.particleDrag = new MicroPoint();
this.frequency = 0.1;
this.lifespan = 3;
this.bounce = 0;
this._quantity = 0;
this._counter = 0;
this._explode = true;
this.on = false;
this._point = new MicroPoint();
}
/**
* The X position of the top left corner of the emitter in world space.
*/
public x: number;
/**
* The Y position of the top left corner of emitter in world space.
*/
public y: number;
/**
* The width of the emitter. Particles can be randomly generated from anywhere within this box.
*/
public width: number;
/**
* The height of the emitter. Particles can be randomly generated from anywhere within this box.
*/
public height: number;
/**
* The minimum possible velocity of a particle.
* The default value is (-100,-100).
*/
public minParticleSpeed: MicroPoint;
/**
* The maximum possible velocity of a particle.
* The default value is (100,100).
*/
public maxParticleSpeed: MicroPoint;
/**
* The X and Y drag component of particles launched from the emitter.
*/
public particleDrag: MicroPoint;
/**
* The minimum possible angular velocity of a particle. The default value is -360.
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
*/
public minRotation: number;
/**
* The maximum possible angular velocity of a particle. The default value is 360.
* NOTE: rotating particles are more expensive to draw than non-rotating ones!
*/
public maxRotation: number;
/**
* Sets the <code>acceleration.y</code> member of each particle to this value on launch.
*/
public gravity: number;
/**
* Determines whether the emitter is currently emitting particles.
* It is totally safe to directly toggle this.
*/
public on: bool;
/**
* How often a particle is emitted (if emitter is started with Explode == false).
*/
public frequency: number;
/**
* How long each particle lives once it is emitted.
* Set lifespan to 'zero' for particles to live forever.
*/
public lifespan: number;
/**
* How much each particle should bounce. 1 = full bounce, 0 = no bounce.
*/
public bounce: number;
/**
* Set your own particle class type here.
* Default is <code>Particle</code>.
*/
public particleClass;
/**
* Internal helper for deciding how many particles to launch.
*/
private _quantity: number;
/**
* Internal helper for the style of particle emission (all at once, or one at a time).
*/
private _explode: bool;
/**
* Internal helper for deciding when to launch particles or kill them.
*/
private _timer: number;
/**
* Internal counter for figuring out how many particles to launch.
*/
private _counter: number;
/**
* Internal point object, handy for reusing for memory mgmt purposes.
*/
private _point: MicroPoint;
/**
* Clean up memory.
*/
public destroy() {
this.minParticleSpeed = null;
this.maxParticleSpeed = null;
this.particleDrag = null;
this.particleClass = null;
this._point = null;
super.destroy();
}
/**
* This function generates a new array of particle sprites to attach to the emitter.
*
* @param Graphics If you opted to not pre-configure an array of Sprite objects, you can simply pass in a particle image or sprite sheet.
* @param Quantity The number of particles to generate when using the "create from image" option.
* @param BakedRotations How many frames of baked rotation to use (boosts performance). Set to zero to not use baked rotations.
* @param Multiple Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).
* @param Collide Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.
*
* @return This Emitter instance (nice for chaining stuff together, if you're into that).
*/
public makeParticles(Graphics, Quantity: number = 50, BakedRotations: number = 16, Multiple: bool = false, Collide: number = 0): Emitter {
this.maxSize = Quantity;
var totalFrames: number = 1;
/*
if(Multiple)
{
var sprite:Sprite = new Sprite(this._game);
sprite.loadGraphic(Graphics,true);
totalFrames = sprite.frames;
sprite.destroy();
}
*/
var randomFrame: number;
var particle: Particle;
var i: number = 0;
while (i < Quantity)
{
if (this.particleClass == null)
{
particle = new Particle(this._game);
}
else
{
particle = new this.particleClass(this._game);
}
if (Multiple)
{
/*
randomFrame = this._game.math.random()*totalFrames;
if(BakedRotations > 0)
particle.loadRotatedGraphic(Graphics,BakedRotations,randomFrame);
else
{
particle.loadGraphic(Graphics,true);
particle.frame = randomFrame;
}
*/
}
else
{
/*
if (BakedRotations > 0)
particle.loadRotatedGraphic(Graphics,BakedRotations);
else
particle.loadGraphic(Graphics);
*/
if (Graphics)
{
particle.loadGraphic(Graphics);
}
}
if (Collide > 0)
{
particle.allowCollisions = Collision.ANY;
particle.width *= Collide;
particle.height *= Collide;
//particle.centerOffsets();
}
else
{
particle.allowCollisions = Collision.NONE;
}
particle.exists = false;
this.add(particle);
i++;
}
return this;
}
/**
* Called automatically by the game loop, decides when to launch particles and when to "die".
*/
public update() {
if (this.on)
{
if (this._explode)
{
this.on = false;
var i: number = 0;
var l: number = this._quantity;
if ((l <= 0) || (l > this.length))
{
l = this.length;
}
while (i < l)
{
this.emitParticle();
i++;
}
this._quantity = 0;
}
else
{
this._timer += this._game.time.elapsed;
while ((this.frequency > 0) && (this._timer > this.frequency) && this.on)
{
this._timer -= this.frequency;
this.emitParticle();
if ((this._quantity > 0) && (++this._counter >= this._quantity))
{
this.on = false;
this._quantity = 0;
}
}
}
}
super.update();
}
/**
* Call this function to turn off all the particles and the emitter.
*/
public kill() {
this.on = false;
super.kill();
}
/**
* Call this function to start emitting particles.
*
* @param Explode Whether the particles should all burst out at once.
* @param Lifespan How long each particle lives once emitted. 0 = forever.
* @param Frequency Ignored if Explode is set to true. Frequency is how often to emit a particle. 0 = never emit, 0.1 = 1 particle every 0.1 seconds, 5 = 1 particle every 5 seconds.
* @param Quantity How many particles to launch. 0 = "all of the particles".
*/
public start(Explode: bool = true, Lifespan: number = 0, Frequency: number = 0.1, Quantity: number = 0) {
this.revive();
this.visible = true;
this.on = true;
this._explode = Explode;
this.lifespan = Lifespan;
this.frequency = Frequency;
this._quantity += Quantity;
this._counter = 0;
this._timer = 0;
}
/**
* This function can be used both internally and externally to emit the next particle.
*/
public emitParticle() {
var particle: Particle = this.recycle(Particle);
particle.lifespan = this.lifespan;
particle.elasticity = this.bounce;
particle.reset(this.x - (particle.width >> 1) + this._game.math.random() * this.width, this.y - (particle.height >> 1) + this._game.math.random() * this.height);
particle.visible = true;
if (this.minParticleSpeed.x != this.maxParticleSpeed.x)
{
particle.velocity.x = this.minParticleSpeed.x + this._game.math.random() * (this.maxParticleSpeed.x - this.minParticleSpeed.x);
}
else
{
particle.velocity.x = this.minParticleSpeed.x;
}
if (this.minParticleSpeed.y != this.maxParticleSpeed.y)
{
particle.velocity.y = this.minParticleSpeed.y + this._game.math.random() * (this.maxParticleSpeed.y - this.minParticleSpeed.y);
}
else
{
particle.velocity.y = this.minParticleSpeed.y;
}
particle.acceleration.y = this.gravity;
if (this.minRotation != this.maxRotation && this.minRotation !== 0 && this.maxRotation !== 0)
{
particle.angularVelocity = this.minRotation + this._game.math.random() * (this.maxRotation - this.minRotation);
}
else
{
particle.angularVelocity = this.minRotation;
}
if (particle.angularVelocity != 0)
{
particle.angle = this._game.math.random() * 360 - 180;
}
particle.drag.x = this.particleDrag.x;
particle.drag.y = this.particleDrag.y;
particle.onEmit();
}
/**
* A more compact way of setting the width and height of the emitter.
*
* @param Width The desired width of the emitter (particles are spawned randomly within these dimensions).
* @param Height The desired height of the emitter.
*/
public setSize(Width: number, Height: number) {
this.width = Width;
this.height = Height;
}
/**
* A more compact way of setting the X velocity range of the emitter.
*
* @param Min The minimum value for this range.
* @param Max The maximum value for this range.
*/
public setXSpeed(Min: number = 0, Max: number = 0) {
this.minParticleSpeed.x = Min;
this.maxParticleSpeed.x = Max;
}
/**
* A more compact way of setting the Y velocity range of the emitter.
*
* @param Min The minimum value for this range.
* @param Max The maximum value for this range.
*/
public setYSpeed(Min: number = 0, Max: number = 0) {
this.minParticleSpeed.y = Min;
this.maxParticleSpeed.y = Max;
}
/**
* A more compact way of setting the angular velocity constraints of the emitter.
*
* @param Min The minimum value for this range.
* @param Max The maximum value for this range.
*/
public setRotation(Min: number = 0, Max: number = 0) {
this.minRotation = Min;
this.maxRotation = Max;
}
/**
* Change the emitter's midpoint to match the midpoint of a <code>Object</code>.
*
* @param Object The <code>Object</code> that you want to sync up with.
*/
public at(Object) {
Object.getMidpoint(this._point);
this.x = this._point.x - (this.width >> 1);
this.y = this._point.y - (this.height >> 1);
}
}
}
-84
View File
@@ -1,84 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../Basic.d.ts" />
/// <reference path="../Signal.d.ts" />
module Phaser {
class GameObject extends Basic {
constructor(game: Game, x?: number, y?: number, width?: number, height?: number);
private _angle;
static ALIGN_TOP_LEFT: number;
static ALIGN_TOP_CENTER: number;
static ALIGN_TOP_RIGHT: number;
static ALIGN_CENTER_LEFT: number;
static ALIGN_CENTER: number;
static ALIGN_CENTER_RIGHT: number;
static ALIGN_BOTTOM_LEFT: number;
static ALIGN_BOTTOM_CENTER: number;
static ALIGN_BOTTOM_RIGHT: number;
static OUT_OF_BOUNDS_STOP: number;
static OUT_OF_BOUNDS_KILL: number;
public _point: MicroPoint;
public cameraBlacklist: number[];
public bounds: Rectangle;
public worldBounds: Quad;
public outOfBoundsAction: number;
public align: number;
public facing: number;
public alpha: number;
public scale: MicroPoint;
public origin: MicroPoint;
public z: number;
public rotationOffset: number;
public renderRotation: bool;
public immovable: bool;
public velocity: MicroPoint;
public mass: number;
public elasticity: number;
public acceleration: MicroPoint;
public drag: MicroPoint;
public maxVelocity: MicroPoint;
public angularVelocity: number;
public angularAcceleration: number;
public angularDrag: number;
public maxAngular: number;
public scrollFactor: MicroPoint;
public health: number;
public moves: bool;
public touching: number;
public wasTouching: number;
public allowCollisions: number;
public last: MicroPoint;
public inputEnabled: bool;
private _inputOver;
public onInputOver: Signal;
public onInputOut: Signal;
public onInputDown: Signal;
public onInputUp: Signal;
public preUpdate(): void;
public update(): void;
public postUpdate(): void;
private updateInput();
private updateMotion();
public overlaps(ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace?: bool, Camera?: Camera): bool;
public overlapsPoint(point: Point, InScreenSpace?: bool, Camera?: Camera): bool;
public onScreen(Camera?: Camera): bool;
public getScreenXY(point?: MicroPoint, Camera?: Camera): MicroPoint;
public solid : bool;
public getMidpoint(point?: MicroPoint): MicroPoint;
public reset(X: number, Y: number): void;
public isTouching(Direction: number): bool;
public justTouched(Direction: number): bool;
public hurt(Damage: number): void;
public setBounds(x: number, y: number, width: number, height: number): void;
public hideFromCamera(camera: Camera): void;
public showToCamera(camera: Camera): void;
public clearCameraList(): void;
public destroy(): void;
public x : number;
public y : number;
public rotation : number;
public angle : number;
public width : number;
public height : number;
}
}
-600
View File
@@ -1,600 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../Basic.ts" />
/// <reference path="../Signal.ts" />
/**
* Phaser - GameObject
*
* This is the base GameObject on which all other game objects are derived. It contains all the logic required for position,
* motion, size, collision and input.
*/
module Phaser {
export class GameObject extends Basic {
constructor(game: Game, x?: number = 0, y?: number = 0, width?: number = 16, height?: number = 16) {
super(game);
this.bounds = new Rectangle(x, y, width, height);
this.exists = true;
this.active = true;
this.visible = true;
this.alive = true;
this.isGroup = false;
this.alpha = 1;
this.scale = new MicroPoint(1, 1);
this.last = new MicroPoint(x, y);
this.origin = new MicroPoint(this.bounds.halfWidth, this.bounds.halfHeight);
this.align = GameObject.ALIGN_TOP_LEFT;
this.mass = 1;
this.elasticity = 0;
this.health = 1;
this.immovable = false;
this.moves = true;
this.worldBounds = null;
this.touching = Collision.NONE;
this.wasTouching = Collision.NONE;
this.allowCollisions = Collision.ANY;
this.velocity = new MicroPoint();
this.acceleration = new MicroPoint();
this.drag = new MicroPoint();
this.maxVelocity = new MicroPoint(10000, 10000);
this.angle = 0;
this.angularVelocity = 0;
this.angularAcceleration = 0;
this.angularDrag = 0;
this.maxAngular = 10000;
this.cameraBlacklist = [];
this.scrollFactor = new MicroPoint(1, 1);
}
private _angle: number = 0;
public static ALIGN_TOP_LEFT: number = 0;
public static ALIGN_TOP_CENTER: number = 1;
public static ALIGN_TOP_RIGHT: number = 2;
public static ALIGN_CENTER_LEFT: number = 3;
public static ALIGN_CENTER: number = 4;
public static ALIGN_CENTER_RIGHT: number = 5;
public static ALIGN_BOTTOM_LEFT: number = 6;
public static ALIGN_BOTTOM_CENTER: number = 7;
public static ALIGN_BOTTOM_RIGHT: number = 8;
public static OUT_OF_BOUNDS_STOP: number = 0;
public static OUT_OF_BOUNDS_KILL: number = 1;
public _point: MicroPoint;
public cameraBlacklist: number[];
public bounds: Rectangle;
public worldBounds: Quad;
public outOfBoundsAction: number = 0;
public align: number;
public facing: number;
public alpha: number;
public scale: MicroPoint;
public origin: MicroPoint;
public z: number = 0;
// This value is added to the angle of the GameObject.
// For example if you had a sprite drawn facing straight up then you could set
// rotationOffset to 90 and it would correspond correctly with Phasers rotation system
public rotationOffset: number = 0;
public renderRotation: bool = true;
// Physics properties
public immovable: bool;
// Velocity is given in pixels per second. Therefore a velocity of
// 100 will move at a rate of 100 pixels every 1000 ms (1sec). It's not balls-on
// accurate due to the way timers work, but it's pretty close. Expect tolerance
// of +- 10 px. Also that speed assumes no drag
public velocity: MicroPoint;
public mass: number;
public elasticity: number;
public acceleration: MicroPoint;
public drag: MicroPoint;
public maxVelocity: MicroPoint;
public angularVelocity: number;
public angularAcceleration: number;
public angularDrag: number;
public maxAngular: number;
public scrollFactor: MicroPoint;
public health: number;
public moves: bool = true;
public touching: number;
public wasTouching: number;
public allowCollisions: number;
public last: MicroPoint;
// Input
public inputEnabled: bool = false;
private _inputOver: bool = false;
public onInputOver: Phaser.Signal;
public onInputOut: Phaser.Signal;
public onInputDown: Phaser.Signal;
public onInputUp: Phaser.Signal;
public preUpdate() {
// flicker time
this.last.x = this.bounds.x;
this.last.y = this.bounds.y;
}
public update() {
}
public postUpdate() {
if (this.moves)
{
this.updateMotion();
}
if (this.worldBounds != null)
{
if (this.outOfBoundsAction == GameObject.OUT_OF_BOUNDS_KILL)
{
if (this.x < this.worldBounds.x || this.x > this.worldBounds.right || this.y < this.worldBounds.y || this.y > this.worldBounds.bottom)
{
this.kill();
}
}
else
{
if (this.x < this.worldBounds.x)
{
this.x = this.worldBounds.x;
}
else if (this.x > this.worldBounds.right)
{
this.x = this.worldBounds.right;
}
if (this.y < this.worldBounds.y)
{
this.y = this.worldBounds.y;
}
else if (this.y > this.worldBounds.bottom)
{
this.y = this.worldBounds.bottom;
}
}
}
if (this.inputEnabled)
{
this.updateInput();
}
this.wasTouching = this.touching;
this.touching = Collision.NONE;
}
private updateInput() {
}
private updateMotion() {
var delta: number;
var velocityDelta: number;
velocityDelta = (this._game.motion.computeVelocity(this.angularVelocity, this.angularAcceleration, this.angularDrag, this.maxAngular) - this.angularVelocity) / 2;
this.angularVelocity += velocityDelta;
this._angle += this.angularVelocity * this._game.time.elapsed;
this.angularVelocity += velocityDelta;
velocityDelta = (this._game.motion.computeVelocity(this.velocity.x, this.acceleration.x, this.drag.x, this.maxVelocity.x) - this.velocity.x) / 2;
this.velocity.x += velocityDelta;
delta = this.velocity.x * this._game.time.elapsed;
this.velocity.x += velocityDelta;
this.bounds.x += delta;
velocityDelta = (this._game.motion.computeVelocity(this.velocity.y, this.acceleration.y, this.drag.y, this.maxVelocity.y) - this.velocity.y) / 2;
this.velocity.y += velocityDelta;
delta = this.velocity.y * this._game.time.elapsed;
this.velocity.y += velocityDelta;
this.bounds.y += delta;
}
/**
* Checks to see if some <code>GameObject</code> overlaps this <code>GameObject</code> or <code>Group</code>.
* If the group has a LOT of things in it, it might be faster to use <code>Collision.overlaps()</code>.
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
*
* @param ObjectOrGroup The object or group being tested.
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the two objects overlap.
*/
public overlaps(ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
if (ObjectOrGroup.isGroup)
{
var results: bool = false;
var i: number = 0;
var members = <Group> ObjectOrGroup.members;
while (i < length)
{
if (this.overlaps(members[i++], InScreenSpace, Camera))
{
results = true;
}
}
return results;
}
if (!InScreenSpace)
{
return (ObjectOrGroup.x + ObjectOrGroup.width > this.x) && (ObjectOrGroup.x < this.x + this.width) &&
(ObjectOrGroup.y + ObjectOrGroup.height > this.y) && (ObjectOrGroup.y < this.y + this.height);
}
if (Camera == null)
{
Camera = this._game.camera;
}
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
this.getScreenXY(this._point, Camera);
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
}
/**
* Checks to see if this <code>GameObject</code> were located at the given position, would it overlap the <code>GameObject</code> or <code>Group</code>?
* This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size numbero account.
* WARNING: Currently tilemaps do NOT support screen space overlap checks!
*
* @param X The X position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param Y The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.
* @param ObjectOrGroup The object or group being tested.
* @param InScreenSpace Whether to take scroll factors numbero account when checking for overlap. Default is false, or "only compare in world space."
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the two objects overlap.
*/
public overlapsAt(X: number, Y: number, ObjectOrGroup, InScreenSpace: bool = false, Camera: Camera = null): bool {
if (ObjectOrGroup.isGroup)
{
var results: bool = false;
var basic;
var i: number = 0;
var members = ObjectOrGroup.members;
while (i < length)
{
if (this.overlapsAt(X, Y, members[i++], InScreenSpace, Camera))
{
results = true;
}
}
return results;
}
if (!InScreenSpace)
{
return (ObjectOrGroup.x + ObjectOrGroup.width > X) && (ObjectOrGroup.x < X + this.width) &&
(ObjectOrGroup.y + ObjectOrGroup.height > Y) && (ObjectOrGroup.y < Y + this.height);
}
if (Camera == null)
{
Camera = this._game.camera;
}
var objectScreenPos: Point = ObjectOrGroup.getScreenXY(null, Camera);
this._point.x = X - Camera.scroll.x * this.scrollFactor.x; //copied from getScreenXY()
this._point.y = Y - Camera.scroll.y * this.scrollFactor.y;
this._point.x += (this._point.x > 0) ? 0.0000001 : -0.0000001;
this._point.y += (this._point.y > 0) ? 0.0000001 : -0.0000001;
return (objectScreenPos.x + ObjectOrGroup.width > this._point.x) && (objectScreenPos.x < this._point.x + this.width) &&
(objectScreenPos.y + ObjectOrGroup.height > this._point.y) && (objectScreenPos.y < this._point.y + this.height);
}
/**
* Checks to see if a point in 2D world space overlaps this <code>GameObject</code>.
*
* @param Point The point in world space you want to check.
* @param InScreenSpace Whether to take scroll factors into account when checking for overlap.
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether or not the point overlaps this object.
*/
public overlapsPoint(point: Point, InScreenSpace: bool = false, Camera: Camera = null): bool {
if (!InScreenSpace)
{
return (point.x > this.x) && (point.x < this.x + this.width) && (point.y > this.y) && (point.y < this.y + this.height);
}
if (Camera == null)
{
Camera = this._game.camera;
}
var X: number = point.x - Camera.scroll.x;
var Y: number = point.y - Camera.scroll.y;
this.getScreenXY(this._point, Camera);
return (X > this._point.x) && (X < this._point.x + this.width) && (Y > this._point.y) && (Y < this._point.y + this.height);
}
/**
* Check and see if this object is currently on screen.
*
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
*
* @return Whether the object is on screen or not.
*/
public onScreen(Camera: Camera = null): bool {
if (Camera == null)
{
Camera = this._game.camera;
}
this.getScreenXY(this._point, Camera);
return (this._point.x + this.width > 0) && (this._point.x < Camera.width) && (this._point.y + this.height > 0) && (this._point.y < Camera.height);
}
/**
* Call this to figure out the on-screen position of the object.
*
* @param Camera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
* @param Point Takes a <code>MicroPoint</code> object and assigns the post-scrolled X and Y values of this object to it.
*
* @return The <code>MicroPoint</code> you passed in, or a new <code>Point</code> if you didn't pass one, containing the screen X and Y position of this object.
*/
public getScreenXY(point: MicroPoint = null, Camera: Camera = null): MicroPoint {
if (point == null)
{
point = new MicroPoint();
}
if (Camera == null)
{
Camera = this._game.camera;
}
point.x = this.x - Camera.scroll.x * this.scrollFactor.x;
point.y = this.y - Camera.scroll.y * this.scrollFactor.y;
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
return point;
}
/**
* Whether the object collides or not. For more control over what directions
* the object will collide from, use collision constants (like LEFT, FLOOR, etc)
* to set the value of allowCollisions directly.
*/
public get solid(): bool {
return (this.allowCollisions & Collision.ANY) > Collision.NONE;
}
/**
* @private
*/
public set solid(Solid: bool) {
if (Solid)
{
this.allowCollisions = Collision.ANY;
}
else
{
this.allowCollisions = Collision.NONE;
}
}
/**
* Retrieve the midpoint of this object in world coordinates.
*
* @Point Allows you to pass in an existing <code>Point</code> object if you're so inclined. Otherwise a new one is created.
*
* @return A <code>Point</code> object containing the midpoint of this object in world coordinates.
*/
public getMidpoint(point: MicroPoint = null): MicroPoint {
if (point == null)
{
point = new MicroPoint();
}
point.copyFrom(this.bounds.center);
return point;
}
/**
* Handy for reviving game objects.
* Resets their existence flags and position.
*
* @param X The new X position of this object.
* @param Y The new Y position of this object.
*/
public reset(X: number, Y: number) {
this.revive();
this.touching = Collision.NONE;
this.wasTouching = Collision.NONE;
this.x = X;
this.y = Y;
this.last.x = X;
this.last.y = Y;
this.velocity.x = 0;
this.velocity.y = 0;
}
/**
* Handy for checking if this object is touching a particular surface.
* For slightly better performance you can just &amp; the value directly numbero <code>touching</code>.
* However, this method is good for readability and accessibility.
*
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
*
* @return Whether the object is touching an object in (any of) the specified direction(s) this frame.
*/
public isTouching(Direction: number): bool {
return (this.touching & Direction) > Collision.NONE;
}
/**
* Handy for checking if this object is just landed on a particular surface.
*
* @param Direction Any of the collision flags (e.g. LEFT, FLOOR, etc).
*
* @return Whether the object just landed on (any of) the specified surface(s) this frame.
*/
public justTouched(Direction: number): bool {
return ((this.touching & Direction) > Collision.NONE) && ((this.wasTouching & Direction) <= Collision.NONE);
}
/**
* Reduces the "health" variable of this sprite by the amount specified in Damage.
* Calls kill() if health drops to or below zero.
*
* @param Damage How much health to take away (use a negative number to give a health bonus).
*/
public hurt(Damage: number) {
this.health = this.health - Damage;
if (this.health <= 0)
{
this.kill();
}
}
/**
* Set the world bounds that this GameObject can exist within. By default a GameObject can exist anywhere
* in the world. But by setting the bounds (which are given in world dimensions, not screen dimensions)
* it can be stopped from leaving the world, or a section of it.
*/
public setBounds(x: number, y: number, width: number, height: number) {
this.worldBounds = new Quad(x, y, width, height);
}
/**
* If you do not wish this object to be visible to a specific camera, pass the camera here.
*/
public hideFromCamera(camera: Camera) {
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
{
this.cameraBlacklist.push(camera.ID);
}
}
public showToCamera(camera: Camera) {
if (this.cameraBlacklist.indexOf(camera.ID) !== -1)
{
this.cameraBlacklist.slice(this.cameraBlacklist.indexOf(camera.ID), 1);
}
}
public clearCameraList() {
this.cameraBlacklist.length = 0;
}
public destroy() {
}
public get x(): number {
return this.bounds.x;
}
public set x(value: number) {
this.bounds.x = value;
}
public get y(): number {
return this.bounds.y;
}
public set y(value: number) {
this.bounds.y = value;
}
public get rotation(): number {
return this._angle;
}
public set rotation(value: number) {
this._angle = this._game.math.wrap(value, 360, 0);
}
public get angle(): number {
return this._angle;
}
public set angle(value: number) {
this._angle = this._game.math.wrap(value, 360, 0);
}
public set width(value:number) {
this.bounds.width = value;
}
public set height(value:number) {
this.bounds.height = value;
}
public get width(): number {
return this.bounds.width;
}
public get height(): number {
return this.bounds.height;
}
}
}
-40
View File
@@ -1,40 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class GeomSprite extends GameObject {
constructor(game: Game, x?: number, y?: number);
private _dx;
private _dy;
private _dw;
private _dh;
public type: number;
static UNASSIGNED: number;
static CIRCLE: number;
static LINE: number;
static POINT: number;
static RECTANGLE: number;
public circle: Circle;
public line: Line;
public point: Point;
public rect: Rectangle;
public renderOutline: bool;
public renderFill: bool;
public lineWidth: number;
public lineColor: string;
public fillColor: string;
public loadCircle(circle: Circle): GeomSprite;
public loadLine(line: Line): GeomSprite;
public loadPoint(point: Point): GeomSprite;
public loadRectangle(rect: Rectangle): GeomSprite;
public createCircle(diameter: number): GeomSprite;
public createLine(x: number, y: number): GeomSprite;
public createPoint(): GeomSprite;
public createRectangle(width: number, height: number): GeomSprite;
public refresh(): void;
public update(): void;
public inCamera(camera: Rectangle): bool;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
public renderPoint(offsetX, offsetY, point, size): void;
public renderDebugInfo(x: number, y: number, color?: string): void;
public collide(source: GeomSprite): bool;
}
}
-11
View File
@@ -1,11 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="Sprite.d.ts" />
module Phaser {
class Particle extends Sprite {
constructor(game: Game);
public lifespan: number;
public friction: number;
public update(): void;
public onEmit(): void;
}
}
-108
View File
@@ -1,108 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="Sprite.ts" />
/**
* Phaser - Particle
*
* This is a simple particle class that extends a Sprite to have a slightly more
* specialised behaviour. It is used exclusively by the Emitter class and can be extended as required.
*/
module Phaser {
export class Particle extends Sprite {
/**
* Instantiate a new particle. Like <code>Sprite</code>, all meaningful creation
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
*/
constructor(game: Game) {
super(game);
this.lifespan = 0;
this.friction = 500;
}
/**
* How long this particle lives before it disappears.
* NOTE: this is a maximum, not a minimum; the object
* could get recycled before its lifespan is up.
*/
public lifespan: number;
/**
* Determines how quickly the particles come to rest on the ground.
* Only used if the particle has gravity-like acceleration applied.
* @default 500
*/
public friction: number;
/**
* The particle's main update logic. Basically it checks to see if it should
* be dead yet, and then has some special bounce behavior if there is some gravity on it.
*/
public update() {
//lifespan behavior
if (this.lifespan <= 0)
{
return;
}
this.lifespan -= this._game.time.elapsed;
if (this.lifespan <= 0)
{
this.kill();
}
//simpler bounce/spin behavior for now
if (this.touching)
{
if (this.angularVelocity != 0)
{
this.angularVelocity = -this.angularVelocity;
}
}
if (this.acceleration.y > 0) //special behavior for particles with gravity
{
if (this.touching & Collision.FLOOR)
{
this.drag.x = this.friction;
if (!(this.wasTouching & Collision.FLOOR))
{
if (this.velocity.y < -this.elasticity * 10)
{
if (this.angularVelocity != 0)
{
this.angularVelocity *= -this.elasticity;
}
}
else
{
this.velocity.y = 0;
this.angularVelocity = 0;
}
}
}
else
{
this.drag.x = 0;
}
}
}
/**
* Triggered whenever this object is launched by a <code>Emitter</code>.
* You can override this to add custom behavior like a sound or AI or something.
*/
public onEmit() {
}
}
}
-22
View File
@@ -1,22 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../geom/Quad.d.ts" />
module Phaser {
class ScrollRegion {
constructor(x: number, y: number, width: number, height: number, speedX: number, speedY: number);
private _A;
private _B;
private _C;
private _D;
private _bounds;
private _scroll;
private _anchorWidth;
private _anchorHeight;
private _inverseWidth;
private _inverseHeight;
public visible: bool;
public scrollSpeed: MicroPoint;
public update(delta: number): void;
public render(context: CanvasRenderingContext2D, texture, dx: number, dy: number, dw: number, dh: number): void;
private crop(context, texture, srcX, srcY, srcW, srcH, destX, destY, destW, destH, offsetX, offsetY);
}
}
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../geom/Quad.d.ts" />
/// <reference path="ScrollRegion.d.ts" />
module Phaser {
class ScrollZone extends GameObject {
constructor(game: Game, key: string, x?: number, y?: number, width?: number, height?: number);
private _texture;
private _dynamicTexture;
private _dx;
private _dy;
private _dw;
private _dh;
public currentRegion: ScrollRegion;
public regions: ScrollRegion[];
public flipped: bool;
public addRegion(x: number, y: number, width: number, height: number, speedX?: number, speedY?: number): ScrollRegion;
public setSpeed(x: number, y: number): ScrollZone;
public update(): void;
public inCamera(camera: Rectangle): bool;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
private createRepeatingTexture(regionWidth, regionHeight);
}
}
-208
View File
@@ -1,208 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../geom/Quad.ts" />
/// <reference path="ScrollRegion.ts" />
/**
* Phaser - ScrollZone
*
* Creates a scrolling region of the given width and height from an image in the cache.
* The ScrollZone can be positioned anywhere in-world like a normal game object, re-act to physics, collision, etc.
* The image within it is scrolled via ScrollRegions and their scrollSpeed.x/y properties.
* If you create a scroll zone larger than the given source image it will create a DynamicTexture and fill it with a pattern of the source image.
*/
module Phaser {
export class ScrollZone extends GameObject {
constructor(game: Game, key:string, x: number = 0, y: number = 0, width?: number = 0, height?: number = 0) {
super(game, x, y, width, height);
this.regions = [];
if (this._game.cache.getImage(key))
{
this._texture = this._game.cache.getImage(key);
this.width = this._texture.width;
this.height = this._texture.height;
if (width > this._texture.width || height > this._texture.height)
{
// Create our repeating texture (as the source image wasn't large enough for the requested size)
this.createRepeatingTexture(width, height);
this.width = width;
this.height = height;
}
// Create a default ScrollRegion at the requested size
this.addRegion(0, 0, this.width, this.height);
// If the zone is smaller than the image itself then shrink the bounds
if ((width < this._texture.width || height < this._texture.height) && width !== 0 && height !== 0)
{
this.width = width;
this.height = height;
}
}
}
private _texture;
private _dynamicTexture: DynamicTexture = null;
// local rendering related temp vars to help avoid gc spikes
private _dx: number = 0;
private _dy: number = 0;
private _dw: number = 0;
private _dh: number = 0;
public currentRegion: ScrollRegion;
public regions: ScrollRegion[];
public flipped: bool = false;
public addRegion(x: number, y: number, width: number, height: number, speedX?:number = 0, speedY?:number = 0):ScrollRegion {
if (x > this.width || y > this.height || x < 0 || y < 0 || (x + width) > this.width || (y + height) > this.height)
{
throw Error('Invalid ScrollRegion defined. Cannot be larger than parent ScrollZone');
return;
}
this.currentRegion = new ScrollRegion(x, y, width, height, speedX, speedY);
this.regions.push(this.currentRegion);
return this.currentRegion;
}
public setSpeed(x: number, y: number) {
if (this.currentRegion)
{
this.currentRegion.scrollSpeed.setTo(x, y);
}
return this;
}
public update() {
for (var i = 0; i < this.regions.length; i++)
{
this.regions[i].update(this._game.time.delta);
}
}
public inCamera(camera: Rectangle): bool {
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx = this.bounds.x - (camera.x * this.scrollFactor.x);
this._dy = this.bounds.y - (camera.y * this.scrollFactor.x);
this._dw = this.bounds.width * this.scale.x;
this._dh = this.bounds.height * this.scale.y;
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
}
else
{
return camera.intersects(this.bounds, this.bounds.length);
}
}
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
// Render checks
if (this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false)
{
return false;
}
// Alpha
if (this.alpha !== 1)
{
var globalAlpha = this._game.stage.context.globalAlpha;
this._game.stage.context.globalAlpha = this.alpha;
}
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
this._dw = this.bounds.width * this.scale.x;
this._dh = this.bounds.height * this.scale.y;
// Apply camera difference
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx -= (camera.worldView.x * this.scrollFactor.x);
this._dy -= (camera.worldView.y * this.scrollFactor.y);
}
// Rotation - needs to work from origin point really, but for now from center
if (this.angle !== 0 || this.flipped == true)
{
this._game.stage.context.save();
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
if (this.angle !== 0)
{
this._game.stage.context.rotate(this.angle * (Math.PI / 180));
}
this._dx = -(this._dw / 2);
this._dy = -(this._dh / 2);
if (this.flipped == true)
{
this._game.stage.context.scale(-1, 1);
}
}
this._dx = Math.round(this._dx);
this._dy = Math.round(this._dy);
this._dw = Math.round(this._dw);
this._dh = Math.round(this._dh);
for (var i = 0; i < this.regions.length; i++)
{
if (this._dynamicTexture)
{
this.regions[i].render(this._game.stage.context, this._dynamicTexture.canvas, this._dx, this._dy, this._dw, this._dh);
}
else
{
this.regions[i].render(this._game.stage.context, this._texture, this._dx, this._dy, this._dw, this._dh);
}
}
if (globalAlpha > -1)
{
this._game.stage.context.globalAlpha = globalAlpha;
}
return true;
}
private createRepeatingTexture(regionWidth: number, regionHeight: number) {
// Work out how many we'll need of the source image to make it tile properly
var tileWidth = Math.ceil(this._texture.width / regionWidth) * regionWidth;
var tileHeight = Math.ceil(this._texture.height / regionHeight) * regionHeight;
this._dynamicTexture = new DynamicTexture(this._game, tileWidth, tileHeight);
this._dynamicTexture.context.rect(0, 0, tileWidth, tileHeight);
this._dynamicTexture.context.fillStyle = this._dynamicTexture.context.createPattern(this._texture, "repeat");
this._dynamicTexture.context.fill();
}
}
}
-34
View File
@@ -1,34 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../AnimationManager.d.ts" />
/// <reference path="GameObject.d.ts" />
/// <reference path="../system/Camera.d.ts" />
module Phaser {
class Sprite extends GameObject {
constructor(game: Game, x?: number, y?: number, key?: string);
private _texture;
private _dynamicTexture;
private _sx;
private _sy;
private _sw;
private _sh;
private _dx;
private _dy;
private _dw;
private _dh;
public animations: AnimationManager;
public renderDebug: bool;
public renderDebugColor: string;
public renderDebugPointColor: string;
public flipped: bool;
public loadGraphic(key: string): Sprite;
public loadDynamicTexture(texture: DynamicTexture): Sprite;
public makeGraphic(width: number, height: number, color?: number): Sprite;
public inCamera(camera: Rectangle): bool;
public postUpdate(): void;
public frame : number;
public frameName : string;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool;
private renderBounds(camera, cameraOffsetX, cameraOffsetY);
public renderDebugInfo(x: number, y: number, color?: string): void;
}
}
-351
View File
@@ -1,351 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../AnimationManager.ts" />
/// <reference path="GameObject.ts" />
/// <reference path="../system/Camera.ts" />
/**
* Phaser - Sprite
*
* The Sprite GameObject is an extension of the core GameObject that includes support for animation and dynamic textures.
* It's probably the most used GameObject of all.
*/
module Phaser {
export class Sprite extends GameObject {
constructor(game: Game, x?: number = 0, y?: number = 0, key?: string = null) {
super(game, x, y);
this._texture = null;
this.animations = new AnimationManager(this._game, this);
if (key !== null)
{
this.loadGraphic(key);
}
else
{
this.bounds.width = 16;
this.bounds.height = 16;
}
}
private _texture;
private _dynamicTexture: bool = false;
// local rendering related temp vars to help avoid gc spikes
private _sx: number = 0;
private _sy: number = 0;
private _sw: number = 0;
private _sh: number = 0;
private _dx: number = 0;
private _dy: number = 0;
private _dw: number = 0;
private _dh: number = 0;
public animations: AnimationManager;
public renderDebug: bool = false;
public renderDebugColor: string = 'rgba(0,255,0,0.5)';
public renderDebugPointColor: string = 'rgba(255,255,255,1)';
public flipped: bool = false;
public loadGraphic(key: string): Sprite {
if (this._game.cache.getImage(key) !== null)
{
if (this._game.cache.isSpriteSheet(key) == false)
{
this._texture = this._game.cache.getImage(key);
this.bounds.width = this._texture.width;
this.bounds.height = this._texture.height;
}
else
{
this._texture = this._game.cache.getImage(key);
this.animations.loadFrameData(this._game.cache.getFrameData(key));
}
this._dynamicTexture = false;
}
return this;
}
public loadDynamicTexture(texture: DynamicTexture): Sprite {
this._texture = texture;
this.bounds.width = this._texture.width;
this.bounds.height = this._texture.height;
this._dynamicTexture = true;
return this;
}
public makeGraphic(width: number, height: number, color: number = 0xffffffff): Sprite {
this._texture = null;
this.width = width;
this.height = height;
this._dynamicTexture = false;
return this;
}
public inCamera(camera: Rectangle): bool {
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx = this.bounds.x - (camera.x * this.scrollFactor.x);
this._dy = this.bounds.y - (camera.y * this.scrollFactor.x);
this._dw = this.bounds.width * this.scale.x;
this._dh = this.bounds.height * this.scale.y;
return (camera.right > this._dx) && (camera.x < this._dx + this._dw) && (camera.bottom > this._dy) && (camera.y < this._dy + this._dh);
}
else
{
return camera.intersects(this.bounds, this.bounds.length);
}
}
public postUpdate() {
this.animations.update();
super.postUpdate();
}
public set frame(value: number) {
this.animations.frame = value;
}
public get frame(): number {
return this.animations.frame;
}
public set frameName(value: string) {
this.animations.frameName = value;
}
public get frameName(): string {
return this.animations.frameName;
}
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): bool {
// Render checks
if (this.visible == false || this.scale.x == 0 || this.scale.y == 0 || this.alpha < 0.1 || this.cameraBlacklist.indexOf(camera.ID) !== -1 || this.inCamera(camera.worldView) == false)
{
return false;
}
// Alpha
if (this.alpha !== 1)
{
var globalAlpha = this._game.stage.context.globalAlpha;
this._game.stage.context.globalAlpha = this.alpha;
}
this._sx = 0;
this._sy = 0;
this._sw = this.bounds.width;
this._sh = this.bounds.height;
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
this._dw = this.bounds.width * this.scale.x;
this._dh = this.bounds.height * this.scale.y;
if (this.align == GameObject.ALIGN_TOP_CENTER)
{
this._dx -= this.bounds.halfWidth * this.scale.x;
}
else if (this.align == GameObject.ALIGN_TOP_RIGHT)
{
this._dx -= this.bounds.width * this.scale.x;
}
else if (this.align == GameObject.ALIGN_CENTER_LEFT)
{
this._dy -= this.bounds.halfHeight * this.scale.y;
}
else if (this.align == GameObject.ALIGN_CENTER)
{
this._dx -= this.bounds.halfWidth * this.scale.x;
this._dy -= this.bounds.halfHeight * this.scale.y;
}
else if (this.align == GameObject.ALIGN_CENTER_RIGHT)
{
this._dx -= this.bounds.width * this.scale.x;
this._dy -= this.bounds.halfHeight * this.scale.y;
}
else if (this.align == GameObject.ALIGN_BOTTOM_LEFT)
{
this._dy -= this.bounds.height * this.scale.y;
}
else if (this.align == GameObject.ALIGN_BOTTOM_CENTER)
{
this._dx -= this.bounds.halfWidth * this.scale.x;
this._dy -= this.bounds.height * this.scale.y;
}
else if (this.align == GameObject.ALIGN_BOTTOM_RIGHT)
{
this._dx -= this.bounds.width * this.scale.x;
this._dy -= this.bounds.height * this.scale.y;
}
if (this._dynamicTexture == false && this.animations.currentFrame !== null)
{
this._sx = this.animations.currentFrame.x;
this._sy = this.animations.currentFrame.y;
if (this.animations.currentFrame.trimmed)
{
this._dx += this.animations.currentFrame.spriteSourceSizeX;
this._dy += this.animations.currentFrame.spriteSourceSizeY;
}
}
// Apply camera difference
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx -= (camera.worldView.x * this.scrollFactor.x);
this._dy -= (camera.worldView.y * this.scrollFactor.y);
}
// Rotation - needs to work from origin point really, but for now from center
if (this.angle !== 0 || this.rotationOffset !== 0 || this.flipped == true)
{
this._game.stage.context.save();
this._game.stage.context.translate(this._dx + (this._dw / 2), this._dy + (this._dh / 2));
if (this.renderRotation == true && (this.angle !== 0 || this.rotationOffset !== 0))
{
this._game.stage.context.rotate((this.rotationOffset + this.angle) * (Math.PI / 180));
}
this._dx = -(this._dw / 2);
this._dy = -(this._dh / 2);
if (this.flipped == true)
{
this._game.stage.context.scale(-1, 1);
}
}
this._sx = Math.round(this._sx);
this._sy = Math.round(this._sy);
this._sw = Math.round(this._sw);
this._sh = Math.round(this._sh);
this._dx = Math.round(this._dx);
this._dy = Math.round(this._dy);
this._dw = Math.round(this._dw);
this._dh = Math.round(this._dh);
if (this._texture != null)
{
if (this._dynamicTexture)
{
this._game.stage.context.drawImage(
this._texture.canvas, // Source Image
this._sx, // Source X (location within the source image)
this._sy, // Source Y
this._sw, // Source Width
this._sh, // Source Height
this._dx, // Destination X (where on the canvas it'll be drawn)
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
}
else
{
this._game.stage.context.drawImage(
this._texture, // Source Image
this._sx, // Source X (location within the source image)
this._sy, // Source Y
this._sw, // Source Width
this._sh, // Source Height
this._dx, // Destination X (where on the canvas it'll be drawn)
this._dy, // Destination Y
this._dw, // Destination Width (always same as Source Width unless scaled)
this._dh // Destination Height (always same as Source Height unless scaled)
);
}
}
else
{
this._game.stage.context.fillStyle = 'rgb(255,255,255)';
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
}
if (this.flipped === true || this.rotation !== 0 || this.rotationOffset !== 0)
{
//this._game.stage.context.translate(0, 0);
this._game.stage.context.restore();
}
if (this.renderDebug)
{
this.renderBounds(camera, cameraOffsetX, cameraOffsetY);
}
if (globalAlpha > -1)
{
this._game.stage.context.globalAlpha = globalAlpha;
}
return true;
}
// Renders the bounding box around this Sprite and the contact points. Useful for visually debugging.
private renderBounds(camera:Camera, cameraOffsetX:number, cameraOffsetY:number) {
this._dx = cameraOffsetX + (this.bounds.topLeft.x - camera.worldView.x);
this._dy = cameraOffsetY + (this.bounds.topLeft.y - camera.worldView.y);
this._game.stage.context.fillStyle = this.renderDebugColor;
this._game.stage.context.fillRect(this._dx, this._dy, this._dw, this._dh);
this._game.stage.context.fillStyle = this.renderDebugPointColor;
var hw = this.bounds.halfWidth * this.scale.x;
var hh = this.bounds.halfHeight * this.scale.y;
var sw = (this.bounds.width * this.scale.x) - 1;
var sh = (this.bounds.height * this.scale.y) - 1;
this._game.stage.context.fillRect(this._dx, this._dy, 1, 1); // top left
this._game.stage.context.fillRect(this._dx + hw, this._dy, 1, 1); // top center
this._game.stage.context.fillRect(this._dx + sw, this._dy, 1, 1); // top right
this._game.stage.context.fillRect(this._dx, this._dy + hh, 1, 1); // left center
this._game.stage.context.fillRect(this._dx + hw, this._dy + hh, 1, 1); // center
this._game.stage.context.fillRect(this._dx + sw, this._dy + hh, 1, 1); // right center
this._game.stage.context.fillRect(this._dx, this._dy + sh, 1, 1); // bottom left
this._game.stage.context.fillRect(this._dx + hw, this._dy + sh, 1, 1); // bottom center
this._game.stage.context.fillRect(this._dx + sw, this._dy + sh, 1, 1); // bottom right
}
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
this._game.stage.context.fillStyle = color;
this._game.stage.context.fillText('Sprite: ' + this.name + ' (' + this.bounds.width + ' x ' + this.bounds.height + ')', x, y);
this._game.stage.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.angle.toFixed(1), x, y + 14);
this._game.stage.context.fillText('dx: ' + this._dx.toFixed(1) + ' dy: ' + this._dy.toFixed(1) + ' dw: ' + this._dw.toFixed(1) + ' dh: ' + this._dh.toFixed(1), x, y + 28);
this._game.stage.context.fillText('sx: ' + this._sx.toFixed(1) + ' sy: ' + this._sy.toFixed(1) + ' sw: ' + this._sw.toFixed(1) + ' sh: ' + this._sh.toFixed(1), x, y + 42);
}
}
}
-31
View File
@@ -1,31 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="GameObject.d.ts" />
/// <reference path="../system/TilemapLayer.d.ts" />
/// <reference path="../system/Tile.d.ts" />
module Phaser {
class Tilemap extends GameObject {
constructor(game: Game, key: string, mapData: string, format: number, resizeWorld?: bool, tileWidth?: number, tileHeight?: number);
static FORMAT_CSV: number;
static FORMAT_TILED_JSON: number;
public tiles: Tile[];
public layers: TilemapLayer[];
public currentLayer: TilemapLayer;
public collisionLayer: TilemapLayer;
public mapFormat: number;
public update(): void;
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number): void;
private parseCSV(data, key, tileWidth, tileHeight);
private parseTiledJSON(data, key);
private generateTiles(qty);
public widthInPixels : number;
public heightInPixels : number;
public setCollisionRange(start: number, end: number, collision?: number, resetCollisions?: bool): void;
public setCollisionByIndex(values: number[], collision?: number, resetCollisions?: bool): void;
public getTile(x: number, y: number, layer?: number): Tile;
public getTileFromWorldXY(x: number, y: number, layer?: number): Tile;
public getTileFromInputXY(layer?: number): Tile;
public getTileOverlaps(object: GameObject): bool;
public collide(objectOrGroup?, callback?): bool;
public collideGameObject(object: GameObject): bool;
}
}
-298
View File
@@ -1,298 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="GameObject.ts" />
/// <reference path="../system/TilemapLayer.ts" />
/// <reference path="../system/Tile.ts" />
/**
* Phaser - Tilemap
*
* This GameObject allows for the display of a tilemap within the game world. Tile maps consist of an image, tile data and a size.
* Internally it creates a TilemapLayer for each layer in the tilemap.
*/
module Phaser {
export class Tilemap extends GameObject {
constructor(game: Game, key: string, mapData: string, format: number, resizeWorld: bool = true, tileWidth?: number = 0, tileHeight?: number = 0) {
super(game);
this.isGroup = false;
this.tiles = [];
this.layers = [];
this.mapFormat = format;
switch (format)
{
case Tilemap.FORMAT_CSV:
this.parseCSV(game.cache.getText(mapData), key, tileWidth, tileHeight);
break;
case Tilemap.FORMAT_TILED_JSON:
this.parseTiledJSON(game.cache.getText(mapData), key);
break;
}
if (this.currentLayer && resizeWorld)
{
this._game.world.setSize(this.currentLayer.widthInPixels, this.currentLayer.heightInPixels, true);
}
}
private _tempCollisionData;
public static FORMAT_CSV: number = 0;
public static FORMAT_TILED_JSON: number = 1;
public tiles : Tile[];
public layers : TilemapLayer[];
public currentLayer: TilemapLayer;
public collisionLayer: TilemapLayer;
public collisionCallback = null;
public collisionCallbackContext;
public mapFormat: number;
public update() {
}
public render(camera: Camera, cameraOffsetX: number, cameraOffsetY: number) {
if (this.cameraBlacklist.indexOf(camera.ID) == -1)
{
// Loop through the layers
for (var i = 0; i < this.layers.length; i++)
{
this.layers[i].render(camera, cameraOffsetX, cameraOffsetY);
}
}
}
private parseCSV(data: string, key: string, tileWidth: number, tileHeight: number) {
var layer: TilemapLayer = new TilemapLayer(this._game, this, key, Tilemap.FORMAT_CSV, 'TileLayerCSV' + this.layers.length.toString(), tileWidth, tileHeight);
// Trim any rogue whitespace from the data
data = data.trim();
var rows = data.split("\n");
for (var i = 0; i < rows.length; i++)
{
var column = rows[i].split(",");
if (column.length > 0)
{
layer.addColumn(column);
}
}
layer.updateBounds();
var tileQuantity = layer.parseTileOffsets();
this.currentLayer = layer;
this.collisionLayer = layer;
this.layers.push(layer);
this.generateTiles(tileQuantity);
}
private parseTiledJSON(data: string, key: string) {
// Trim any rogue whitespace from the data
data = data.trim();
var json = JSON.parse(data);
for (var i = 0; i < json.layers.length; i++)
{
var layer: TilemapLayer = new TilemapLayer(this._game, this, key, Tilemap.FORMAT_TILED_JSON, json.layers[i].name, json.tilewidth, json.tileheight);
layer.alpha = json.layers[i].opacity;
layer.visible = json.layers[i].visible;
layer.tileMargin = json.tilesets[0].margin;
layer.tileSpacing = json.tilesets[0].spacing;
var c = 0;
var row;
for (var t = 0; t < json.layers[i].data.length; t++)
{
if (c == 0)
{
row = [];
}
row.push(json.layers[i].data[t]);
c++;
if (c == json.layers[i].width)
{
layer.addColumn(row);
c = 0;
}
}
layer.updateBounds();
var tileQuantity = layer.parseTileOffsets();
this.currentLayer = layer;
this.collisionLayer = layer;
this.layers.push(layer);
}
this.generateTiles(tileQuantity);
}
private generateTiles(qty:number) {
for (var i = 0; i < qty; i++)
{
this.tiles.push(new Tile(this._game, this, i, this.currentLayer.tileWidth, this.currentLayer.tileHeight));
}
}
public get widthInPixels(): number {
return this.currentLayer.widthInPixels;
}
public get heightInPixels(): number {
return this.currentLayer.heightInPixels;
}
// Tile Collision
public setCollisionCallback(context, callback) {
this.collisionCallbackContext = context;
this.collisionCallback = callback;
}
public setCollisionRange(start: number, end: number, collision?:number = Collision.ANY, resetCollisions?: bool = false, separateX?: bool = true, separateY?: bool = true) {
for (var i = start; i < end; i++)
{
this.tiles[i].setCollision(collision, resetCollisions, separateX, separateY);
}
}
public setCollisionByIndex(values:number[], collision?:number = Collision.ANY, resetCollisions?: bool = false, separateX?: bool = true, separateY?: bool = true) {
for (var i = 0; i < values.length; i++)
{
this.tiles[values[i]].setCollision(collision, resetCollisions, separateX, separateY);
}
}
// Tile Management
public getTileByIndex(value: number):Tile {
if (this.tiles[value])
{
return this.tiles[value];
}
return null;
}
public getTile(x: number, y: number, layer?: number = 0):Tile {
return this.tiles[this.layers[layer].getTileIndex(x, y)];
}
public getTileFromWorldXY(x: number, y: number, layer?: number = 0):Tile {
return this.tiles[this.layers[layer].getTileFromWorldXY(x, y)];
}
public getTileFromInputXY(layer?: number = 0):Tile {
return this.tiles[this.layers[layer].getTileFromWorldXY(this._game.input.worldX, this._game.input.worldY)];
}
public getTileOverlaps(object: GameObject) {
return this.currentLayer.getTileOverlaps(object);
}
// COLLIDE
public collide(objectOrGroup = null, callback = null, context = null) {
if (callback !== null && context !== null)
{
this.collisionCallback = callback;
this.collisionCallbackContext = context;
}
if (objectOrGroup == null)
{
objectOrGroup = this._game.world.group;
}
// Group?
if (objectOrGroup.isGroup == false)
{
this.collideGameObject(objectOrGroup);
}
else
{
objectOrGroup.forEachAlive(this, this.collideGameObject, true);
}
}
public collideGameObject(object: GameObject): bool {
if (object !== this && object.immovable == false && object.exists == true && object.allowCollisions != Collision.NONE)
{
this._tempCollisionData = this.collisionLayer.getTileOverlaps(object);
if (this.collisionCallback !== null && this._tempCollisionData.length > 0)
{
this.collisionCallback.call(this.collisionCallbackContext, object, this._tempCollisionData);
}
return true;
}
else
{
return false;
}
}
public putTile(x: number, y: number, index: number, layer?: number = 0) {
this.layers[layer].putTile(x, y, index);
}
// Set current layer
// Set layer order?
// Delete tiles of certain type
// Erase tiles
}
}
-34
View File
@@ -1,34 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Circle {
constructor(x?: number, y?: number, diameter?: number);
private _diameter;
private _radius;
public x: number;
public y: number;
public diameter : number;
public radius : number;
public circumference(): number;
public bottom : number;
public left : number;
public right : number;
public top : number;
public area : number;
public isEmpty : bool;
public intersectCircleLine(line: Line): bool;
public clone(output?: Circle): Circle;
public contains(x: number, y: number): bool;
public containsPoint(point: Point): bool;
public containsCircle(circle: Circle): bool;
public copyFrom(source: Circle): Circle;
public copyTo(target: Circle): Circle;
public distanceTo(target: any, round?: bool): number;
public equals(toCompare: Circle): bool;
public intersects(toIntersect: Circle): bool;
public circumferencePoint(angle: number, asDegrees?: bool, output?: Point): Point;
public offset(dx: number, dy: number): Circle;
public offsetPoint(point: Point): Circle;
public setTo(x: number, y: number, diameter: number): Circle;
public toString(): string;
}
}
-15
View File
@@ -1,15 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class IntersectResult {
public result: bool;
public x: number;
public y: number;
public x1: number;
public y1: number;
public x2: number;
public y2: number;
public width: number;
public height: number;
public setTo(x1: number, y1: number, x2?: number, y2?: number, width?: number, height?: number): void;
}
}
-96
View File
@@ -1,96 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - IntersectResult
*
* A light-weight result object to hold the results of an intersection. For when you need more than just true/false.
*/
module Phaser {
export class IntersectResult {
/**
* Did they intersect or not?
* @property result
* @type Boolean
*/
result: bool = false;
/**
* @property x
* @type Number
*/
x: number;
/**
* @property y
* @type Number
*/
y: number;
/**
* @property x1
* @type Number
*/
x1: number;
/**
* @property y1
* @type Number
*/
y1: number;
/**
* @property x2
* @type Number
*/
x2: number;
/**
* @property y2
* @type Number
*/
y2: number;
/**
* @property width
* @type Number
*/
width: number;
/**
* @property height
* @type Number
*/
height: number;
/**
*
* @method setTo
* @param {Number} x1
* @param {Number} y1
* @param {Number} [x2]
* @param {Number} [y2]
* @param {Number} [width]
* @param {Number} [height]
*/
setTo(x1: number, y1: number, x2?: number = 0, y2?: number = 0, width?: number = 0, height?: number = 0) {
this.x = x1;
this.y = y1;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.width = width;
this.height = height;
}
}
}
-27
View File
@@ -1,27 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Line {
constructor(x1?: number, y1?: number, x2?: number, y2?: number);
public x1: number;
public y1: number;
public x2: number;
public y2: number;
public clone(output?: Line): Line;
public copyFrom(source: Line): Line;
public copyTo(target: Line): Line;
public setTo(x1?: number, y1?: number, x2?: number, y2?: number): Line;
public width : number;
public height : number;
public length : number;
public getY(x: number): number;
public angle : number;
public slope : number;
public perpSlope : number;
public yIntercept : number;
public isPointOnLine(x: number, y: number): bool;
public isPointOnLineSegment(x: number, y: number): bool;
public intersectLineLine(line): any;
public perp(x: number, y: number, output?: Line): Line;
public toString(): string;
}
}
-16
View File
@@ -1,16 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class MicroPoint {
constructor(x?: number, y?: number, parent?: any);
private _x;
private _y;
public parent: any;
public x : number;
public y : number;
public copyFrom(source: any): MicroPoint;
public copyTo(target: any): MicroPoint;
public setTo(x: number, y: number, callParent?: bool): MicroPoint;
public equals(toCompare): bool;
public toString(): string;
}
}
-170
View File
@@ -1,170 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - MicroPoint
*
* The MicroPoint object represents a location in a two-dimensional coordinate system,
* where x represents the horizontal axis and y represents the vertical axis.
* It is different to the Point class in that it doesn't contain any of the help methods like add/substract/distanceTo, etc.
* Use a MicroPoint when all you literally need is a solid container for x and y (such as in the Rectangle class).
*/
module Phaser {
export class MicroPoint {
/**
* Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
* @class MicroPoint
* @constructor
* @param {Number} x The horizontal position of this point (default 0)
* @param {Number} y The vertical position of this point (default 0)
**/
constructor(x: number = 0, y: number = 0, parent?:any = null) {
this._x = x;
this._y = y;
this.parent = parent;
}
private _x: number;
private _y: number;
public parent: any;
/**
* The x coordinate of the top-left corner of the rectangle
* @property x
* @type Number
**/
public get x(): number {
return this._x;
}
/**
* The y coordinate of the top-left corner of the rectangle
* @property y
* @type Number
**/
public get y(): number {
return this._y;
}
/**
* The x coordinate of the top-left corner of the rectangle
* @property x
* @type Number
**/
public set x(value: number) {
this._x = value;
if (this.parent)
{
this.parent.updateBounds();
}
}
/**
* The y coordinate of the top-left corner of the rectangle
* @property y
* @type Number
**/
public set y(value:number) {
this._y = value;
if (this.parent)
{
this.parent.updateBounds();
}
}
/**
* Copies the x and y values from any given object to this MicroPoint.
* @method copyFrom
* @param {any} source - The object to copy from.
* @return {MicroPoint} This MicroPoint object. Useful for chaining method calls.
**/
public copyFrom(source: any): MicroPoint {
return this.setTo(source.x, source.y);
}
/**
* Copies the x and y values from this MicroPoint to any given object.
* @method copyTo
* @param {any} target - The object to copy to.
* @return {any} The target object.
**/
public copyTo(target: any): MicroPoint {
target.x = this._x;
target.y = this._y;
return target;
}
/**
* Sets the x and y values of this MicroPoint object to the given coordinates.
* @method setTo
* @param {Number} x - The horizontal position of this point.
* @param {Number} y - The vertical position of this point.
* @return {MicroPoint} This MicroPoint object. Useful for chaining method calls.
**/
public setTo(x: number, y: number, callParent?:bool = true): MicroPoint {
this._x = x;
this._y = y;
if (this.parent != null && callParent == true)
{
this.parent.updateBounds();
}
return this;
}
/**
* Determines whether this MicroPoint object and the given object are equal. They are equal if they have the same x and y values.
* @method equals
* @param {any} point - The object to compare against. Must have x and y properties.
* @return {Boolean} A value of true if the object is equal to this MicroPoin object; false if it is not equal.
**/
public equals(toCompare): bool {
if (this._x === toCompare.x && this._y === toCompare.y)
{
return true;
}
else
{
return false;
}
}
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the instance.
**/
public toString(): string {
return '[{MicroPoint (x=' + this._x + ' y=' + this._y + ')}]';
}
}
}
-28
View File
@@ -1,28 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Point {
constructor(x?: number, y?: number);
public x: number;
public y: number;
public add(toAdd: Point, output?: Point): Point;
public addTo(x?: number, y?: number): Point;
public subtractFrom(x?: number, y?: number): Point;
public invert(): Point;
public clamp(min: number, max: number): Point;
public clampX(min: number, max: number): Point;
public clampY(min: number, max: number): Point;
public clone(output?: Point): Point;
public copyFrom(source: Point): Point;
public copyTo(target: Point): Point;
public distanceTo(target: Point, round?: bool): number;
static distanceBetween(pointA: Point, pointB: Point, round?: bool): number;
public distanceCompare(target: Point, distance: number): bool;
public equals(toCompare: Point): bool;
public interpolate(pointA, pointB, f): void;
public offset(dx: number, dy: number): Point;
public polar(length, angle): void;
public setTo(x: number, y: number): Point;
public subtract(point: Point, output?: Point): Point;
public toString(): string;
}
}
-341
View File
@@ -1,341 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - Point
*
* The Point object represents a location in a two-dimensional coordinate system, where x represents the horizontal axis and y represents the vertical axis.
*/
module Phaser {
export class Point {
/**
* Creates a new point. If you pass no parameters to this method, a point is created at (0,0).
* @class Point
* @constructor
* @param {Number} x The horizontal position of this point (default 0)
* @param {Number} y The vertical position of this point (default 0)
**/
constructor(x: number = 0, y: number = 0) {
this.setTo(x, y);
}
/**
* The horizontal position of this point (default 0)
* @property x
* @type Number
**/
public x: number;
/**
* The vertical position of this point (default 0)
* @property y
* @type Number
**/
public y: number;
/**
* Adds the coordinates of another point to the coordinates of this point to create a new point.
* @method add
* @param {Point} point - The point to be added.
* @return {Point} The new Point object.
**/
public add(toAdd: Point, output?: Point = new Point): Point {
return output.setTo(this.x + toAdd.x, this.y + toAdd.y);
}
/**
* Adds the given values to the coordinates of this point and returns it
* @method addTo
* @param {Number} x - The amount to add to the x value of the point
* @param {Number} y - The amount to add to the x value of the point
* @return {Point} This Point object.
**/
public addTo(x?: number = 0, y?: number = 0): Point {
return this.setTo(this.x + x, this.y + y);
}
/**
* Adds the given values to the coordinates of this point and returns it
* @method addTo
* @param {Number} x - The amount to add to the x value of the point
* @param {Number} y - The amount to add to the x value of the point
* @return {Point} This Point object.
**/
public subtractFrom(x?: number = 0, y?: number = 0): Point {
return this.setTo(this.x - x, this.y - y);
}
/**
* Inverts the x and y values of this point
* @method invert
* @return {Point} This Point object.
**/
public invert(): Point {
return this.setTo(this.y, this.x);
}
/**
* Clamps this Point object to be between the given min and max
* @method clamp
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
public clamp(min: number, max: number): Point {
this.clampX(min, max);
this.clampY(min, max);
return this;
}
/**
* Clamps the x value of this Point object to be between the given min and max
* @method clampX
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
public clampX(min: number, max: number): Point {
this.x = Math.max(Math.min(this.x, max), min);
return this;
}
/**
* Clamps the y value of this Point object to be between the given min and max
* @method clampY
* @param {number} The minimum value to clamp this Point to
* @param {number} The maximum value to clamp this Point to
* @return {Point} This Point object.
**/
public clampY(min: number, max: number): Point {
this.x = Math.max(Math.min(this.x, max), min);
this.y = Math.max(Math.min(this.y, max), min);
return this;
}
/**
* Creates a copy of this Point.
* @method clone
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
* @return {Point} The new Point object.
**/
public clone(output?: Point = new Point): Point {
return output.setTo(this.x, this.y);
}
/**
* Copies the point data from the source Point object into this Point object.
* @method copyFrom
* @param {Point} source - The point to copy from.
* @return {Point} This Point object. Useful for chaining method calls.
**/
public copyFrom(source: Point): Point {
return this.setTo(source.x, source.y);
}
/**
* Copies the point data from this Point object to the given target Point object.
* @method copyTo
* @param {Point} target - The point to copy to.
* @return {Point} The target Point object.
**/
public copyTo(target: Point): Point {
return target.setTo(this.x, this.y);
}
/**
* Returns the distance from this Point object to the given Point object.
* @method distanceFrom
* @param {Point} target - The destination Point object.
* @param {Boolean} round - Round the distance to the nearest integer (default false)
* @return {Number} The distance between this Point object and the destination Point object.
**/
public distanceTo(target: Point, round?: bool = false): number {
var dx = this.x - target.x;
var dy = this.y - target.y;
if (round === true)
{
return Math.round(Math.sqrt(dx * dx + dy * dy));
}
else
{
return Math.sqrt(dx * dx + dy * dy);
}
}
/**
* Returns the distance between the two Point objects.
* @method distanceBetween
* @param {Point} pointA - The first Point object.
* @param {Point} pointB - The second Point object.
* @param {Boolean} round - Round the distance to the nearest integer (default false)
* @return {Number} The distance between the two Point objects.
**/
public static distanceBetween(pointA: Point, pointB: Point, round?: bool = false): number {
var dx: number = pointA.x - pointB.x;
var dy: number = pointA.y - pointB.y;
if (round === true)
{
return Math.round(Math.sqrt(dx * dx + dy * dy));
}
else
{
return Math.sqrt(dx * dx + dy * dy);
}
}
/**
* Returns true if the distance between this point and a target point is greater than or equal a specified distance.
* This avoids using a costly square root operation
* @method distanceCompare
* @param {Point} target - The Point object to use for comparison.
* @param {Number} distance - The distance to use for comparison.
* @return {Boolena} True if distance is >= specified distance.
**/
public distanceCompare(target: Point, distance: number): bool {
if (this.distanceTo(target) >= distance)
{
return true;
}
else
{
return false;
}
}
/**
* Determines whether this Point object and the given point object are equal. They are equal if they have the same x and y values.
* @method equals
* @param {Point} point - The point to compare against.
* @return {Boolean} A value of true if the object is equal to this Point object; false if it is not equal.
**/
public equals(toCompare: Point): bool {
if (this.x === toCompare.x && this.y === toCompare.y)
{
return true;
}
else
{
return false;
}
}
/**
* Determines a point between two specified points. The parameter f determines where the new interpolated point is located relative to the two end points specified by parameters pt1 and pt2.
* The closer the value of the parameter f is to 1.0, the closer the interpolated point is to the first point (parameter pt1). The closer the value of the parameter f is to 0, the closer the interpolated point is to the second point (parameter pt2).
* @method interpolate
* @param {Point} pointA - The first Point object.
* @param {Point} pointB - The second Point object.
* @param {Number} f - The level of interpolation between the two points. Indicates where the new point will be, along the line between pt1 and pt2. If f=1, pt1 is returned; if f=0, pt2 is returned.
* @return {Point} The new interpolated Point object.
**/
public interpolate(pointA, pointB, f) {
}
/**
* Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value.
* The value of dy is added to the original value of y to create the new y value.
* @method offset
* @param {Number} dx - The amount by which to offset the horizontal coordinate, x.
* @param {Number} dy - The amount by which to offset the vertical coordinate, y.
* @return {Point} This Point object. Useful for chaining method calls.
**/
public offset(dx: number, dy: number): Point {
this.x += dx;
this.y += dy;
return this;
}
/**
* Converts a pair of polar coordinates to a Cartesian point coordinate.
* @method polar
* @param {Number} length - The length coordinate of the polar pair.
* @param {Number} angle - The angle, in radians, of the polar pair.
* @return {Point} The new Cartesian Point object.
**/
public polar(length, angle) {
}
/**
* Sets the x and y values of this Point object to the given coordinates.
* @method setTo
* @param {Number} x - The horizontal position of this point.
* @param {Number} y - The vertical position of this point.
* @return {Point} This Point object. Useful for chaining method calls.
**/
public setTo(x: number, y: number): Point {
this.x = x;
this.y = y;
return this;
}
/**
* Subtracts the coordinates of another point from the coordinates of this point to create a new point.
* @method subtract
* @param {Point} point - The point to be subtracted.
* @param {Point} output Optional Point object. If given the values will be set into this object, otherwise a brand new Point object will be created and returned.
* @return {Point} The new Point object.
**/
public subtract(point: Point, output?: Point = new Point): Point {
return output.setTo(this.x - point.x, this.y - point.y);
}
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the instance.
**/
public toString(): string {
return '[{Point (x=' + this.x + ' y=' + this.y + ')}]';
}
}
}
-19
View File
@@ -1,19 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Quad {
constructor(x?: number, y?: number, width?: number, height?: number);
public x: number;
public y: number;
public width: number;
public height: number;
public setTo(x: number, y: number, width: number, height: number): Quad;
public left : number;
public right : number;
public top : number;
public bottom : number;
public halfWidth : number;
public halfHeight : number;
public intersects(q, t?: number): bool;
public toString(): string;
}
}
-106
View File
@@ -1,106 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - Quad
*
* A Quad object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
* Very much like a Rectangle only without all of the additional methods and properties of that class.
*/
module Phaser {
export class Quad {
/**
* Creates a new Quad object with the top-left corner specified by the x and y parameters and with the specified width and height parameters. If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created.
* @class Quad
* @constructor
* @param {Number} x The x coordinate of the top-left corner of the quad.
* @param {Number} y The y coordinate of the top-left corner of the quad.
* @param {Number} width The width of the quad.
* @param {Number} height The height of the quad.
* @return {Quad } This object
**/
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
this.setTo(x, y, width, height);
}
public x: number;
public y: number;
public width: number;
public height: number;
/**
* Sets the Quad to the specified size.
* @method setTo
* @param {Number} x The x coordinate of the top-left corner of the quad.
* @param {Number} y The y coordinate of the top-left corner of the quad.
* @param {Number} width The width of the quad.
* @param {Number} height The height of the quad.
* @return {Quad} This object
**/
public setTo(x: number, y: number, width: number, height: number): Quad {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
return this;
}
public get left(): number {
return this.x;
}
public get right(): number {
return this.x + this.width;
}
public get top(): number {
return this.y;
}
public get bottom(): number {
return this.y + this.height;
}
public get halfWidth(): number {
return this.width / 2;
}
public get halfHeight(): number {
return this.height / 2;
}
/**
* Determines whether the object specified intersects (overlaps) with this Quad object.
* This method checks the x, y, width, and height properties of the specified Quad object to see if it intersects with this Quad object.
* @method intersects
* @param {Object} q The object to check for intersection with this Quad. Must have left/right/top/bottom properties (Rectangle, Quad).
* @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0
* @return {Boolean} A value of true if the specified object intersects with this Quad; otherwise false.
**/
public intersects(q, t?: number = 0): bool {
return !(q.left > this.right + t || q.right < this.left - t || q.top > this.bottom + t || q.bottom < this.top - t);
}
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the object.
**/
public toString(): string {
return "[{Quad (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + ")}]";
}
}
}
-57
View File
@@ -1,57 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="MicroPoint.d.ts" />
module Phaser {
class Rectangle {
constructor(x?: number, y?: number, width?: number, height?: number);
private _tempX;
private _tempY;
private _tempWidth;
private _tempHeight;
public x : number;
public y : number;
public topLeft: MicroPoint;
public topCenter: MicroPoint;
public topRight: MicroPoint;
public leftCenter: MicroPoint;
public center: MicroPoint;
public rightCenter: MicroPoint;
public bottomLeft: MicroPoint;
public bottomCenter: MicroPoint;
public bottomRight: MicroPoint;
private _width;
private _height;
private _halfWidth;
private _halfHeight;
public length: number;
public updateBounds(): void;
public width : number;
public height : number;
public halfWidth : number;
public halfHeight : number;
public bottom : number;
public left : number;
public right : number;
public size(output?: Point): Point;
public volume : number;
public perimeter : number;
public top : number;
public clone(output?: Rectangle): Rectangle;
public contains(x: number, y: number): bool;
public containsPoint(point: any): bool;
public containsRect(rect: Rectangle): bool;
public copyFrom(source: Rectangle): Rectangle;
public copyTo(target: Rectangle): Rectangle;
public equals(toCompare: Rectangle): bool;
public inflate(dx: number, dy: number): Rectangle;
public inflatePoint(point: Point): Rectangle;
public intersection(toIntersect: Rectangle, output?: Rectangle): Rectangle;
public intersects(r2: Rectangle, t?: number): bool;
public isEmpty : bool;
public offset(dx: number, dy: number): Rectangle;
public offsetPoint(point: Point): Rectangle;
public setEmpty(): Rectangle;
public setTo(x: number, y: number, width: number, height: number): Rectangle;
public union(toUnion: Rectangle, output?: Rectangle): Rectangle;
public toString(): string;
}
}
-810
View File
@@ -1,810 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="MicroPoint.ts" />
/**
* Phaser - Rectangle
*
* A Rectangle object is an area defined by its position, as indicated by its top-left corner (x,y) and width and height.
*/
module Phaser {
export class Rectangle {
/**
* Creates a new Rectangle object with the top-left corner specified by the x and y parameters and with the specified width and height parameters.
* If you call this function without parameters, a rectangle with x, y, width, and height properties set to 0 is created.
* @class Rectangle
* @constructor
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
* @param {Number} width The width of the rectangle.
* @param {Number} height The height of the rectangle.
* @return {Rectangle} This rectangle object
**/
constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
this._width = width;
if (width > 0)
{
this._halfWidth = Math.round(width / 2);
}
this._height = height;
if (height > 0)
{
this._halfHeight = Math.round(height / 2);
}
this.length = Math.max(this._width, this._height);
this.topLeft = new MicroPoint(x, y, this);
this.topCenter = new MicroPoint(x + this._halfWidth, y, this);
this.topRight = new MicroPoint(x + this._width - 1, y, this);
this.leftCenter = new MicroPoint(x, y + this._halfHeight, this);
this.center = new MicroPoint(x + this._halfWidth, y + this._halfHeight, this);
this.rightCenter = new MicroPoint(x + this._width - 1, y + this._halfHeight, this);
this.bottomLeft = new MicroPoint(x, y + this._height - 1, this);
this.bottomCenter = new MicroPoint(x + this._halfWidth, y + this._height - 1, this);
this.bottomRight = new MicroPoint(x + this._width - 1, y + this._height - 1, this);
}
private _tempX: number = null;
private _tempY: number = null;
private _tempWidth: number = null;
private _tempHeight: number = null;
/**
* The x coordinate of the top-left corner of the rectangle
* @property x
* @type Number
**/
public get x(): number {
return this.topLeft.x;
}
/**
* The y coordinate of the top-left corner of the rectangle
* @property y
* @type Number
**/
public get y(): number {
return this.topLeft.y;
}
/**
* The x coordinate of the top-left corner of the rectangle
* @property x
* @type Number
**/
public set x(value: number) {
this.topLeft.x = value;
}
/**
* The y coordinate of the top-left corner of the rectangle
* @property y
* @type Number
**/
public set y(value:number) {
this.topLeft.y = value;
}
/**
* The x and y coordinate of the top-left corner of the rectangle (same as x/y)
* @property topLeft
* @type MicroPoint
**/
public topLeft: MicroPoint;
/**
* The x and y coordinate of the top-center of the rectangle
* @property topCenter
* @type MicroPoint
**/
public topCenter: MicroPoint;
/**
* The x and y coordinate of the top-right corner of the rectangle
* @property topRight
* @type MicroPoint
**/
public topRight: MicroPoint;
/**
* The x and y coordinate of the left-center of the rectangle
* @property leftCenter
* @type MicroPoint
**/
public leftCenter: MicroPoint;
/**
* The x and y coordinate of the center of the rectangle
* @property center
* @type MicroPoint
**/
public center: MicroPoint;
/**
* The x and y coordinate of the right-center of the rectangle
* @property rightCenter
* @type MicroPoint
**/
public rightCenter: MicroPoint;
/**
* The x and y coordinate of the bottom-left corner of the rectangle
* @property bottomLeft
* @type MicroPoint
**/
public bottomLeft: MicroPoint;
/**
* The x and y coordinate of the bottom-center of the rectangle
* @property bottomCenter
* @type MicroPoint
**/
public bottomCenter: MicroPoint;
/**
* The x and y coordinate of the bottom-right corner of the rectangle
* @property bottomRight
* @type MicroPoint
**/
public bottomRight: MicroPoint;
/**
* The width of the rectangle
* @property width
* @type Number
**/
private _width: number = 0;
/**
* The height of the rectangle
* @property height
* @type Number
**/
private _height: number = 0;
/**
* Half of the width of the rectangle
* @property halfWidth
* @type Number
**/
private _halfWidth: number = 0;
/**
* Half of the height of the rectangle
* @property halfHeight
* @type Number
**/
private _halfHeight: number = 0;
/**
* The size of the longest side (width or height)
* @property length
* @type Number
**/
public length: number = 0;
/**
* Updates all of the MicroPoints based on the values of width and height.
* You should not normally call this directly.
**/
public updateBounds() {
if (this._tempWidth !== null)
{
this._width = this._tempWidth;
this._halfWidth = 0;
if (this._width > 0)
{
this._halfWidth = Math.round(this._width / 2);
}
}
if (this._tempHeight !== null)
{
this._height = this._tempHeight;
this._halfHeight = 0;
if (this._height > 0)
{
this._halfHeight = Math.round(this._height / 2);
}
}
this.length = Math.max(this._width, this._height);
if (this._tempX !== null && this._tempY !== null)
{
this.topLeft.setTo(this._tempX, this._tempY, false);
}
else if (this._tempX !== null && this._tempY == null)
{
this.topLeft.setTo(this._tempX, this.topLeft.y, false);
}
else if (this._tempX == null && this._tempY !== null)
{
this.topLeft.setTo(this.topLeft.x, this._tempY, false);
}
else
{
this.topLeft.setTo(this.x, this.y, false);
}
this.topCenter.setTo(this.x + this._halfWidth, this.y, false);
this.topRight.setTo(this.x + this._width - 1, this.y, false);
this.leftCenter.setTo(this.x, this.y + this._halfHeight, false);
this.center.setTo(this.x + this._halfWidth, this.y + this._halfHeight, false);
this.rightCenter.setTo(this.x + this._width - 1, this.y + this._halfHeight, false);
this.bottomLeft.setTo(this.x, this.y + this._height - 1, false);
this.bottomCenter.setTo(this.x + this._halfWidth, this.y + this._height - 1, false);
this.bottomRight.setTo(this.x + this._width - 1, this.y + this._height - 1, false);
this._tempX = null;
this._tempY = null;
this._tempWidth = null;
this._tempHeight = null;
}
/**
* The width of the rectangle
* @property width
* @type Number
**/
public set width(value: number) {
this._width = value;
this._halfWidth = Math.round(value / 2);
this.updateBounds();
}
/**
* The height of the rectangle
* @property height
* @type Number
**/
public set height(value: number) {
this._height = value;
this._halfHeight = Math.round(value / 2);
this.updateBounds();
}
/**
* The width of the rectangle
* @property width
* @type Number
**/
public get width(): number {
return this._width;
}
/**
* The height of the rectangle
* @property height
* @type Number
**/
public get height(): number {
return this._height;
}
/**
* Half of the width of the rectangle
* @property halfWidth
* @type Number
**/
public get halfWidth(): number {
return this._halfWidth;
}
/**
* Half of the height of the rectangle
* @property halfHeight
* @type Number
**/
public get halfHeight(): number {
return this._halfHeight;
}
/**
* The sum of the y and height properties.
* Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
* @method bottom
* @return {Number}
**/
public get bottom(): number {
return this.bottomCenter.y;
}
/**
* The sum of the y and height properties.
* Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property.
* @method bottom
* @param {Number} value
**/
public set bottom(value: number) {
if (value < this.y)
{
this._tempHeight = 0;
}
else
{
this._tempHeight = this.y + value;
}
this.updateBounds();
}
/**
* The x coordinate of the top-left corner of the rectangle.
* Changing the left property of a Rectangle object has no effect on the y and height properties.
* However it does affect the width property, whereas changing the x value does not affect the width property.
* @method left
* @ return {number}
**/
public get left(): number {
return this.x;
}
/**
* The x coordinate of the top-left corner of the rectangle.
* Changing the left property of a Rectangle object has no effect on the y and height properties.
* However it does affect the width property, whereas changing the x value does not affect the width property.
* @method left
* @param {Number} value
**/
public set left(value: number) {
var diff = this.x - value;
if (this._width + diff < 0)
{
this._tempWidth = 0;
this._tempX = value;
}
else
{
this._tempWidth = this._width + diff;
this._tempX = value;
}
this.updateBounds();
}
/**
* The sum of the x and width properties.
* Changing the right property of a Rectangle object has no effect on the x, y and height properties.
* However it does affect the width property.
* @method right
* @return {Number}
**/
public get right(): number {
return this.rightCenter.x;
}
/**
* The sum of the x and width properties.
* Changing the right property of a Rectangle object has no effect on the x, y and height properties.
* However it does affect the width property.
* @method right
* @param {Number} value
**/
public set right(value: number) {
if (value < this.topLeft.x)
{
this._tempWidth = 0;
}
else
{
this._tempWidth = (value - this.topLeft.x);
}
this.updateBounds();
}
/**
* The size of the Rectangle object, expressed as a Point object with the values of the width and height properties.
* @method size
* @param {Point} output Optional Point object. If given the values will be set into the object, otherwise a brand new Point object will be created and returned.
* @return {Point} The size of the Rectangle object
**/
public size(output?: Point = new Point): Point {
return output.setTo(this._width, this._height);
}
/**
* The volume of the Rectangle object in pixels, derived from width * height
* @method volume
* @return {Number}
**/
public get volume(): number {
return this._width * this._height;
}
/**
* The perimeter size of the Rectangle object in pixels. This is the sum of all 4 sides.
* @method perimeter
* @return {Number}
**/
public get perimeter(): number {
return (this._width * 2) + (this._height * 2);
}
/**
* The y coordinate of the top-left corner of the rectangle.
* Changing the top property of a Rectangle object has no effect on the x and width properties.
* However it does affect the height property, whereas changing the y value does not affect the height property.
* @method top
* @return {Number}
**/
public get top(): number {
return this.topCenter.y;
}
/**
* The y coordinate of the top-left corner of the rectangle.
* Changing the top property of a Rectangle object has no effect on the x and width properties.
* However it does affect the height property, whereas changing the y value does not affect the height property.
* @method top
* @param {Number} value
**/
public set top(value: number) {
var diff = this.topCenter.y - value;
if (this._height + diff < 0)
{
this._tempHeight = 0;
this._tempY = value;
}
else
{
this._tempHeight = this._height + diff;
this._tempY = value;
}
this.updateBounds();
}
/**
* Returns a new Rectangle object with the same values for the x, y, width, and height properties as the original Rectangle object.
* @method clone
* @param {Rectangle} output Optional Rectangle object. If given the values will be set into the object, otherwise a brand new Rectangle object will be created and returned.
* @return {Rectangle}
**/
public clone(output?: Rectangle = new Rectangle): Rectangle {
return output.setTo(this.x, this.y, this.width, this.height);
}
/**
* Determines whether the specified coordinates are contained within the region defined by this Rectangle object.
* @method contains
* @param {Number} x The x coordinate of the point to test.
* @param {Number} y The y coordinate of the point to test.
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
**/
public contains(x: number, y: number): bool {
if (x >= this.topLeft.x && x <= this.topRight.x && y >= this.topLeft.y && y <= this.bottomRight.y)
{
return true;
}
return false;
}
/**
* Determines whether the specified point is contained within the rectangular region defined by this Rectangle object.
* This method is similar to the Rectangle.contains() method, except that it takes a Point object as a parameter.
* @method containsPoint
* @param {Point} point The point object being checked. Can be Point or any object with .x and .y values.
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
**/
public containsPoint(point: any): bool {
return this.contains(point.x, point.y);
}
/**
* Determines whether the Rectangle object specified by the rect parameter is contained within this Rectangle object.
* A Rectangle object is said to contain another if the second Rectangle object falls entirely within the boundaries of the first.
* @method containsRect
* @param {Rectangle} rect The rectangle object being checked.
* @return {Boolean} A value of true if the Rectangle object contains the specified point; otherwise false.
**/
public containsRect(rect: Rectangle): bool {
// If the given rect has a larger volume than this one then it can never contain it
if (rect.volume > this.volume)
{
return false;
}
if (rect.x >= this.topLeft.x && rect.y >= this.topLeft.y && rect.rightCenter.x <= this.rightCenter.x && rect.bottomCenter.y <= this.bottomCenter.y)
{
return true;
}
return false;
}
/**
* Copies all of rectangle data from the source Rectangle object into the calling Rectangle object.
* @method copyFrom
* @param {Rectangle} rect The source rectangle object to copy from
* @return {Rectangle} This rectangle object
**/
public copyFrom(source: Rectangle): Rectangle {
return this.setTo(source.x, source.y, source.width, source.height);
}
/**
* Copies all the rectangle data from this Rectangle object into the destination Rectangle object.
* @method copyTo
* @param {Rectangle} rect The destination rectangle object to copy in to
* @return {Rectangle} The destination rectangle object
**/
public copyTo(target: Rectangle): Rectangle {
return target.copyFrom(this);
}
/**
* Determines whether the object specified in the toCompare parameter is equal to this Rectangle object.
* This method compares the x, y, width, and height properties of an object against the same properties of this Rectangle object.
* @method equals
* @param {Rectangle} toCompare The rectangle to compare to this Rectangle object.
* @return {Boolean} A value of true if the object has exactly the same values for the x, y, width, and height properties as this Rectangle object; otherwise false.
**/
public equals(toCompare: Rectangle): bool {
if (this.topLeft.equals(toCompare.topLeft) && this.bottomRight.equals(toCompare.bottomRight))
{
return true;
}
return false;
}
/**
* Increases the size of the Rectangle object by the specified amounts.
* The center point of the Rectangle object stays the same, and its size increases to the left and right by the dx value,
* and to the top and the bottom by the dy value.
* @method inflate
* @param {Number} dx The amount to be added to the left side of this Rectangle.
* @param {Number} dy The amount to be added to the bottom side of this Rectangle.
* @return {Rectangle} This Rectangle object.
**/
public inflate(dx: number, dy: number): Rectangle {
this._tempX = this.topLeft.x - dx;
this._tempWidth = this._width + (2 * dx);
this._tempY = this.topLeft.y - dy;
this._tempHeight = this._height + (2 * dy);
this.updateBounds();
return this;
}
/**
* Increases the size of the Rectangle object.
* This method is similar to the Rectangle.inflate() method except it takes a Point object as a parameter.
* @method inflatePoint
* @param {Point} point The x property of this Point object is used to increase the horizontal dimension of the Rectangle object. The y property is used to increase the vertical dimension of the Rectangle object.
* @return {Rectangle} This Rectangle object.
**/
public inflatePoint(point: Point): Rectangle {
return this.inflate(point.x, point.y);
}
/**
* If the Rectangle object specified in the toIntersect parameter intersects with this Rectangle object,
* returns the area of intersection as a Rectangle object. If the rectangles do not intersect, this method
* returns an empty Rectangle object with its properties set to 0.
* @method intersection
* @param {Rectangle} toIntersect The Rectangle object to compare against to see if it intersects with this Rectangle object.
* @param {Rectangle} output Optional Rectangle object. If given the intersection values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
* @return {Rectangle} A Rectangle object that equals the area of intersection. If the rectangles do not intersect, this method returns an empty Rectangle object; that is, a rectangle with its x, y, width, and height properties set to 0.
**/
public intersection(toIntersect: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
if (this.intersects(toIntersect) === true)
{
output.x = Math.max(toIntersect.topLeft.x, this.topLeft.x);
output.y = Math.max(toIntersect.topLeft.y, this.topLeft.y);
output.width = Math.min(toIntersect.rightCenter.x, this.rightCenter.x) - output.x;
output.height = Math.min(toIntersect.bottomCenter.y, this.bottomCenter.y) - output.y;
}
return output;
}
/**
* Determines whether the object specified intersects (overlaps) with this Rectangle object.
* This method checks the x, y, width, and height properties of the specified Rectangle object to see if it intersects with this Rectangle object.
* @method intersects
* @param {Rectangle} r2 The Rectangle object to compare against to see if it intersects with this Rectangle object.
* @param {Number} t A tolerance value to allow for an intersection test with padding, default to 0
* @return {Boolean} A value of true if the specified object intersects with this Rectangle object; otherwise false.
**/
public intersects(r2: Rectangle, t?: number = 0): bool {
return !(r2.left > this.right + t || r2.right < this.left - t || r2.top > this.bottom + t || r2.bottom < this.top - t);
}
/**
* Determines whether or not this Rectangle object is empty.
* @method isEmpty
* @return {Boolean} A value of true if the Rectangle object's width or height is less than or equal to 0; otherwise false.
**/
public get isEmpty(): bool {
if (this.width < 1 || this.height < 1)
{
return true;
}
return false;
}
/**
* Adjusts the location of the Rectangle object, as determined by its top-left corner, by the specified amounts.
* @method offset
* @param {Number} dx Moves the x value of the Rectangle object by this amount.
* @param {Number} dy Moves the y value of the Rectangle object by this amount.
* @return {Rectangle} This Rectangle object.
**/
public offset(dx: number, dy: number): Rectangle {
if (!isNaN(dx) && !isNaN(dy))
{
this.x += dx;
this.y += dy;
}
return this;
}
/**
* Adjusts the location of the Rectangle object using a Point object as a parameter. This method is similar to the Rectangle.offset() method, except that it takes a Point object as a parameter.
* @method offsetPoint
* @param {Point} point A Point object to use to offset this Rectangle object.
* @return {Rectangle} This Rectangle object.
**/
public offsetPoint(point: Point): Rectangle {
return this.offset(point.x, point.y);
}
/**
* Sets all of the Rectangle object's properties to 0. A Rectangle object is empty if its width or height is less than or equal to 0.
* @method setEmpty
* @return {Rectangle} This rectangle object
**/
public setEmpty() {
return this.setTo(0, 0, 0, 0);
}
/**
* Sets the members of Rectangle to the specified values.
* @method setTo
* @param {Number} x The x coordinate of the top-left corner of the rectangle.
* @param {Number} y The y coordinate of the top-left corner of the rectangle.
* @param {Number} width The width of the rectangle in pixels.
* @param {Number} height The height of the rectangle in pixels.
* @return {Rectangle} This rectangle object
**/
public setTo(x: number, y: number, width: number, height: number): Rectangle {
this._tempX = x;
this._tempY = y;
this._tempWidth = width;
this._tempHeight = height;
this.updateBounds();
return this;
}
/**
* Adds two rectangles together to create a new Rectangle object, by filling in the horizontal and vertical space between the two rectangles.
* @method union
* @param {Rectangle} toUnion A Rectangle object to add to this Rectangle object.
* @param {Rectangle} output Optional Rectangle object. If given the new values will be set into this object, otherwise a brand new Rectangle object will be created and returned.
* @return {Rectangle} A Rectangle object that is the union of the two rectangles.
**/
public union(toUnion: Rectangle, output?: Rectangle = new Rectangle): Rectangle {
return output.setTo(
Math.min(toUnion.x, this.x),
Math.min(toUnion.y, this.y),
Math.max(toUnion.right, this.right),
Math.max(toUnion.bottom, this.bottom)
);
}
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the instance.
**/
public toString(): string {
return "[{Rectangle (x=" + this.x + " y=" + this.y + " width=" + this.width + " height=" + this.height + " empty=" + this.isEmpty + ")}]";
}
}
}
-19
View File
@@ -1,19 +0,0 @@
/**
* Phaser
*
* v0.9.5 - April 28th 2013
*
* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
*
* Richard Davey (@photonstorm)
*
* Many thanks to Adam Saltsman (@ADAMATOMIC) for releasing Flixel on which Phaser took a lot of inspiration.
*
* "If you want your children to be intelligent, read them fairy tales."
* "If you want them to be more intelligent, read them more fairy tales."
* -- Albert Einstein
*/
var Phaser;
(function (Phaser) {
Phaser.VERSION = 'Phaser version 0.9.5';
})(Phaser || (Phaser = {}));
-80
View File
@@ -1,80 +0,0 @@
/// <reference path="../gameobjects/Sprite.d.ts" />
/// <reference path="../Game.d.ts" />
module Phaser {
class Camera {
constructor(game: Game, id: number, x: number, y: number, width: number, height: number);
private _game;
private _clip;
private _stageX;
private _stageY;
private _rotation;
private _target;
private _sx;
private _sy;
private _fxFlashColor;
private _fxFlashComplete;
private _fxFlashDuration;
private _fxFlashAlpha;
private _fxFadeColor;
private _fxFadeComplete;
private _fxFadeDuration;
private _fxFadeAlpha;
private _fxShakeIntensity;
private _fxShakeDuration;
private _fxShakeComplete;
private _fxShakeOffset;
private _fxShakeDirection;
private _fxShakePrevX;
private _fxShakePrevY;
static STYLE_LOCKON: number;
static STYLE_PLATFORMER: number;
static STYLE_TOPDOWN: number;
static STYLE_TOPDOWN_TIGHT: number;
static SHAKE_BOTH_AXES: number;
static SHAKE_HORIZONTAL_ONLY: number;
static SHAKE_VERTICAL_ONLY: number;
public ID: number;
public worldView: Rectangle;
public totalSpritesRendered: number;
public scale: MicroPoint;
public scroll: MicroPoint;
public bounds: Rectangle;
public deadzone: Rectangle;
public showBorder: bool;
public borderColor: string;
public opaque: bool;
private _bgColor;
private _bgTexture;
private _bgTextureRepeat;
public showShadow: bool;
public shadowColor: string;
public shadowBlur: number;
public shadowOffset: MicroPoint;
public visible: bool;
public alpha: number;
public inputX: number;
public inputY: number;
public fx: FXManager;
public flash(color?: number, duration?: number, onComplete?, force?: bool): void;
public fade(color?: number, duration?: number, onComplete?, force?: bool): void;
public shake(intensity?: number, duration?: number, onComplete?, force?: bool, direction?: number): void;
public stopFX(): void;
public follow(target: Sprite, style?: number): void;
public focusOnXY(x: number, y: number): void;
public focusOn(point): void;
public setBounds(x?: number, y?: number, width?: number, height?: number): void;
public update(): void;
public render(): void;
public backgroundColor : string;
public setTexture(key: string, repeat?: string): void;
public setPosition(x: number, y: number): void;
public setSize(width: number, height: number): void;
public renderDebugInfo(x: number, y: number, color?: string): void;
public x : number;
public y : number;
public width : number;
public height : number;
public rotation : number;
private checkClip();
}
}
-480
View File
@@ -1,480 +0,0 @@
/// <reference path="../gameobjects/Sprite.ts" />
/// <reference path="../Game.ts" />
/**
* Phaser - Camera
*
* A Camera is your view into the game world. It has a position, size, scale and rotation and renders only those objects
* within its field of view. The game automatically creates a single Stage sized camera on boot, but it can be changed and
* additional cameras created via the CameraManager.
*/
module Phaser {
export class Camera {
/**
* Instantiates a new camera at the specified location, with the specified size and zoom level.
*
* @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
* @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom.
* @param Width The width of the camera display in pixels.
* @param Height The height of the camera display in pixels.
* @param Zoom The initial zoom level of the camera. A zoom level of 2 will make all pixels display at 2x resolution.
*/
constructor(game: Game, id: number, x: number, y: number, width: number, height: number) {
this._game = game;
this.ID = id;
this._stageX = x;
this._stageY = y;
this.fx = new FXManager(this._game, this);
// The view into the world canvas we wish to render
this.worldView = new Rectangle(0, 0, width, height);
this.checkClip();
}
private _game: Game;
private _clip: bool = false;
private _stageX: number;
private _stageY: number;
private _rotation: number = 0;
private _target: Sprite = null;
private _sx: number = 0;
private _sy: number = 0;
public static STYLE_LOCKON: number = 0;
public static STYLE_PLATFORMER: number = 1;
public static STYLE_TOPDOWN: number = 2;
public static STYLE_TOPDOWN_TIGHT: number = 3;
public ID: number;
public worldView: Rectangle;
public totalSpritesRendered: number;
public scale: MicroPoint = new MicroPoint(1, 1);
public scroll: MicroPoint = new MicroPoint(0, 0);
public bounds: Rectangle = null;
public deadzone: Rectangle = null;
// Camera Border
public disableClipping: bool = false;
public showBorder: bool = false;
public borderColor: string = 'rgb(255,255,255)';
// Camera Background Color
public opaque: bool = true;
private _bgColor: string = 'rgb(0,0,0)';
private _bgTexture;
private _bgTextureRepeat: string = 'repeat';
// Camera Shadow
public showShadow: bool = false;
public shadowColor: string = 'rgb(0,0,0)';
public shadowBlur: number = 10;
public shadowOffset: MicroPoint = new MicroPoint(4, 4);
public visible: bool = true;
public alpha: number = 1;
// The x/y position of the current input event in world coordinates
public inputX: number = 0;
public inputY: number = 0;
public fx: FXManager;
public follow(target: Sprite, style?: number = Camera.STYLE_LOCKON) {
this._target = target;
var helper: number;
switch (style)
{
case Camera.STYLE_PLATFORMER:
var w: number = this.width / 8;
var h: number = this.height / 3;
this.deadzone = new Rectangle((this.width - w) / 2, (this.height - h) / 2 - h * 0.25, w, h);
break;
case Camera.STYLE_TOPDOWN:
helper = Math.max(this.width, this.height) / 4;
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
break;
case Camera.STYLE_TOPDOWN_TIGHT:
helper = Math.max(this.width, this.height) / 8;
this.deadzone = new Rectangle((this.width - helper) / 2, (this.height - helper) / 2, helper, helper);
break;
case Camera.STYLE_LOCKON:
default:
this.deadzone = null;
break;
}
}
public focusOnXY(x: number, y: number) {
x += (x > 0) ? 0.0000001 : -0.0000001;
y += (y > 0) ? 0.0000001 : -0.0000001;
this.scroll.x = Math.round(x - this.worldView.halfWidth);
this.scroll.y = Math.round(y - this.worldView.halfHeight);
}
public focusOn(point) {
point.x += (point.x > 0) ? 0.0000001 : -0.0000001;
point.y += (point.y > 0) ? 0.0000001 : -0.0000001;
this.scroll.x = Math.round(point.x - this.worldView.halfWidth);
this.scroll.y = Math.round(point.y - this.worldView.halfHeight);
}
/**
* Specify the boundaries of the world or where the camera is allowed to move.
*
* @param x The smallest X value of your world (usually 0).
* @param y The smallest Y value of your world (usually 0).
* @param width The largest X value of your world (usually the world width).
* @param height The largest Y value of your world (usually the world height).
*/
public setBounds(x: number = 0, y: number = 0, width: number = 0, height: number = 0) {
if (this.bounds == null)
{
this.bounds = new Rectangle();
}
this.bounds.setTo(x, y, width, height);
this.scroll.setTo(0, 0);
this.update();
}
public update() {
this.fx.preUpdate();
if (this._target !== null)
{
if (this.deadzone == null)
{
this.focusOnXY(this._target.x + this._target.origin.x, this._target.y + this._target.origin.y);
}
else
{
var edge: number;
var targetX: number = this._target.x + ((this._target.x > 0) ? 0.0000001 : -0.0000001);
var targetY: number = this._target.y + ((this._target.y > 0) ? 0.0000001 : -0.0000001);
edge = targetX - this.deadzone.x;
if (this.scroll.x > edge)
{
this.scroll.x = edge;
}
edge = targetX + this._target.width - this.deadzone.x - this.deadzone.width;
if (this.scroll.x < edge)
{
this.scroll.x = edge;
}
edge = targetY - this.deadzone.y;
if (this.scroll.y > edge)
{
this.scroll.y = edge;
}
edge = targetY + this._target.height - this.deadzone.y - this.deadzone.height;
if (this.scroll.y < edge)
{
this.scroll.y = edge;
}
}
}
// Make sure we didn't go outside the cameras bounds
if (this.bounds !== null)
{
if (this.scroll.x < this.bounds.left)
{
this.scroll.x = this.bounds.left;
}
if (this.scroll.x > this.bounds.right - this.width)
{
this.scroll.x = (this.bounds.right - this.width) + 1;
}
if (this.scroll.y < this.bounds.top)
{
this.scroll.y = this.bounds.top;
}
if (this.scroll.y > this.bounds.bottom - this.height)
{
this.scroll.y = (this.bounds.bottom - this.height) + 1;
}
}
this.worldView.x = this.scroll.x;
this.worldView.y = this.scroll.y;
// Input values
this.inputX = this.worldView.x + this._game.input.x;
this.inputY = this.worldView.y + this._game.input.y;
this.fx.postUpdate();
}
public render() {
if (this.visible === false || this.alpha < 0.1)
{
return;
}
//if (this._rotation !== 0 || this._clip || this.scale.x !== 1 || this.scale.y !== 1)
//{
//this._game.stage.context.save();
//}
// It may be safer/quicker to just save the context every frame regardless (needs testing on mobile)
this._game.stage.context.save();
this.fx.preRender(this, this._stageX, this._stageY, this.worldView.width, this.worldView.height);
if (this.alpha !== 1)
{
this._game.stage.context.globalAlpha = this.alpha;
}
this._sx = this._stageX;
this._sy = this._stageY;
// Shadow
if (this.showShadow)
{
this._game.stage.context.shadowColor = this.shadowColor;
this._game.stage.context.shadowBlur = this.shadowBlur;
this._game.stage.context.shadowOffsetX = this.shadowOffset.x;
this._game.stage.context.shadowOffsetY = this.shadowOffset.y;
}
// Scale on
if (this.scale.x !== 1 || this.scale.y !== 1)
{
this._game.stage.context.scale(this.scale.x, this.scale.y);
this._sx = this._sx / this.scale.x;
this._sy = this._sy / this.scale.y;
}
// Rotation - translate to the mid-point of the camera
if (this._rotation !== 0)
{
this._game.stage.context.translate(this._sx + this.worldView.halfWidth, this._sy + this.worldView.halfHeight);
this._game.stage.context.rotate(this._rotation * (Math.PI / 180));
// now shift back to where that should actually render
this._game.stage.context.translate(-(this._sx + this.worldView.halfWidth), -(this._sy + this.worldView.halfHeight));
}
// Background
if (this.opaque == true)
{
if (this._bgTexture)
{
this._game.stage.context.fillStyle = this._bgTexture;
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
}
else
{
this._game.stage.context.fillStyle = this._bgColor;
this._game.stage.context.fillRect(this._sx, this._sy, this.worldView.width, this.worldView.height);
}
}
// Shadow off
if (this.showShadow)
{
this._game.stage.context.shadowBlur = 0;
this._game.stage.context.shadowOffsetX = 0;
this._game.stage.context.shadowOffsetY = 0;
}
this.fx.render(this, this._stageX, this._stageY, this.worldView.width, this.worldView.height);
// Clip the camera so we don't get sprites appearing outside the edges
if (this._clip && this.disableClipping == false)
{
this._game.stage.context.beginPath();
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
this._game.stage.context.closePath();
this._game.stage.context.clip();
}
this._game.world.group.render(this, this._sx, this._sy);
if (this.showBorder)
{
this._game.stage.context.strokeStyle = this.borderColor;
this._game.stage.context.lineWidth = 1;
this._game.stage.context.rect(this._sx, this._sy, this.worldView.width, this.worldView.height);
this._game.stage.context.stroke();
}
// Scale off
if (this.scale.x !== 1 || this.scale.y !== 1)
{
this._game.stage.context.scale(1, 1);
}
this.fx.postRender(this, this._sx, this._sy, this.worldView.width, this.worldView.height);
if (this._rotation !== 0 || (this._clip && this.disableClipping == false))
{
this._game.stage.context.translate(0, 0);
}
this._game.stage.context.restore();
if (this.alpha !== 1)
{
this._game.stage.context.globalAlpha = 1;
}
}
public set backgroundColor(color: string) {
this._bgColor = color;
}
public get backgroundColor(): string {
return this._bgColor;
}
public setTexture(key: string, repeat?: string = 'repeat') {
this._bgTexture = this._game.stage.context.createPattern(this._game.cache.getImage(key), repeat);
this._bgTextureRepeat = repeat;
}
public setPosition(x: number, y: number) {
this._stageX = x;
this._stageY = y;
this.checkClip();
}
public setSize(width: number, height: number) {
this.worldView.width = width;
this.worldView.height = height;
this.checkClip();
}
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
this._game.stage.context.fillStyle = color;
this._game.stage.context.fillText('Camera ID: ' + this.ID + ' (' + this.worldView.width + ' x ' + this.worldView.height + ')', x, y);
this._game.stage.context.fillText('X: ' + this._stageX + ' Y: ' + this._stageY + ' Rotation: ' + this._rotation, x, y + 14);
this._game.stage.context.fillText('World X: ' + this.scroll.x.toFixed(1) + ' World Y: ' + this.scroll.y.toFixed(1), x, y + 28);
if (this.bounds)
{
this._game.stage.context.fillText('Bounds: ' + this.bounds.width + ' x ' + this.bounds.height, x, y + 56);
}
}
public get x(): number {
return this._stageX;
}
public set x(value: number) {
this._stageX = value;
this.checkClip();
}
public get y(): number {
return this._stageY;
}
public set y(value: number) {
this._stageY = value;
this.checkClip();
}
public get width(): number {
return this.worldView.width;
}
public set width(value: number) {
if (value > this._game.stage.width)
{
value = this._game.stage.width;
}
this.worldView.width = value;
this.checkClip();
}
public get height(): number {
return this.worldView.height;
}
public set height(value: number) {
if (value > this._game.stage.height)
{
value = this._game.stage.height;
}
this.worldView.height = value;
this.checkClip();
}
public get rotation(): number {
return this._rotation;
}
public set rotation(value: number) {
this._rotation = this._game.math.wrap(value, 360, 0);
}
private checkClip() {
if (this._stageX !== 0 || this._stageY !== 0 || this.worldView.width < this._game.stage.width || this.worldView.height < this._game.stage.height)
{
this._clip = true;
}
else
{
this._clip = false;
}
}
}
}
-49
View File
@@ -1,49 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Device {
constructor();
public desktop: bool;
public iOS: bool;
public android: bool;
public chromeOS: bool;
public linux: bool;
public macOS: bool;
public windows: bool;
public canvas: bool;
public file: bool;
public fileSystem: bool;
public localStorage: bool;
public webGL: bool;
public worker: bool;
public touch: bool;
public css3D: bool;
public arora: bool;
public chrome: bool;
public epiphany: bool;
public firefox: bool;
public ie: bool;
public ieVersion: number;
public mobileSafari: bool;
public midori: bool;
public opera: bool;
public safari: bool;
public webApp: bool;
public audioData: bool;
public webaudio: bool;
public ogg: bool;
public mp3: bool;
public wav: bool;
public m4a: bool;
public iPhone: bool;
public iPhone4: bool;
public iPad: bool;
public pixelRatio: number;
private _checkOS();
private _checkFeatures();
private _checkBrowser();
private _checkAudio();
private _checkDevice();
private _checkCSS3D();
public getAll(): string;
}
}
-9
View File
@@ -1,9 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class LinkedList {
constructor();
public object: Basic;
public next: LinkedList;
public destroy(): void;
}
}
-53
View File
@@ -1,53 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="LinkedList.d.ts" />
module Phaser {
class QuadTree extends Rectangle {
constructor(X: number, Y: number, Width: number, Height: number, Parent?: QuadTree);
static A_LIST: number;
static B_LIST: number;
static divisions: number;
private _canSubdivide;
private _headA;
private _tailA;
private _headB;
private _tailB;
private static _min;
private _northWestTree;
private _northEastTree;
private _southEastTree;
private _southWestTree;
private _leftEdge;
private _rightEdge;
private _topEdge;
private _bottomEdge;
private _halfWidth;
private _halfHeight;
private _midpointX;
private _midpointY;
private static _object;
private static _objectLeftEdge;
private static _objectTopEdge;
private static _objectRightEdge;
private static _objectBottomEdge;
private static _list;
private static _useBothLists;
private static _processingCallback;
private static _notifyCallback;
private static _iterator;
private static _objectHullX;
private static _objectHullY;
private static _objectHullWidth;
private static _objectHullHeight;
private static _checkObjectHullX;
private static _checkObjectHullY;
private static _checkObjectHullWidth;
private static _checkObjectHullHeight;
public destroy(): void;
public load(ObjectOrGroup1: Basic, ObjectOrGroup2?: Basic, NotifyCallback?, ProcessCallback?): void;
public add(ObjectOrGroup: Basic, List: number): void;
private addObject();
private addToList();
public execute(): bool;
private overlapNode();
}
}
-770
View File
@@ -1,770 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="LinkedList.ts" />
/**
* Phaser - QuadTree
*
* A fairly generic quad tree structure for rapid overlap checks. QuadTree is also configured for single or dual list operation.
* You can add items either to its A list or its B list. When you do an overlap check, you can compare the A list to itself,
* or the A list against the B list. Handy for different things!
*/
module Phaser {
export class QuadTree extends Rectangle {
/**
* Instantiate a new Quad Tree node.
*
* @param X The X-coordinate of the point in space.
* @param Y The Y-coordinate of the point in space.
* @param Width Desired width of this node.
* @param Height Desired height of this node.
* @param Parent The parent branch or node. Pass null to create a root.
*/
constructor(X: number, Y: number, Width: number, Height: number, Parent: QuadTree = null) {
super(X, Y, Width, Height);
//console.log('-------- QuadTree',X,Y,Width,Height);
this._headA = this._tailA = new LinkedList();
this._headB = this._tailB = new LinkedList();
//Copy the parent's children (if there are any)
if (Parent != null)
{
//console.log('Parent not null');
var iterator: LinkedList;
var ot: LinkedList;
if (Parent._headA.object != null)
{
iterator = Parent._headA;
//console.log('iterator set to parent headA');
while (iterator != null)
{
if (this._tailA.object != null)
{
ot = this._tailA;
this._tailA = new LinkedList();
ot.next = this._tailA;
}
this._tailA.object = iterator.object;
iterator = iterator.next;
}
}
if (Parent._headB.object != null)
{
iterator = Parent._headB;
//console.log('iterator set to parent headB');
while (iterator != null)
{
if (this._tailB.object != null)
{
ot = this._tailB;
this._tailB = new LinkedList();
ot.next = this._tailB;
}
this._tailB.object = iterator.object;
iterator = iterator.next;
}
}
}
else
{
QuadTree._min = (this.width + this.height) / (2 * QuadTree.divisions);
}
this._canSubdivide = (this.width > QuadTree._min) || (this.height > QuadTree._min);
//console.log('canSubdivided', this._canSubdivide);
//Set up comparison/sort helpers
this._northWestTree = null;
this._northEastTree = null;
this._southEastTree = null;
this._southWestTree = null;
this._leftEdge = this.x;
this._rightEdge = this.x + this.width;
this._halfWidth = this.width / 2;
this._midpointX = this._leftEdge + this._halfWidth;
this._topEdge = this.y;
this._bottomEdge = this.y + this.height;
this._halfHeight = this.height / 2;
this._midpointY = this._topEdge + this._halfHeight;
}
/**
* Flag for specifying that you want to add an object to the A list.
*/
public static A_LIST: number = 0;
/**
* Flag for specifying that you want to add an object to the B list.
*/
public static B_LIST: number = 1;
/**
* Controls the granularity of the quad tree. Default is 6 (decent performance on large and small worlds).
*/
public static divisions: number;
/**
* Whether this branch of the tree can be subdivided or not.
*/
private _canSubdivide: bool;
/**
* Refers to the internal A and B linked lists,
* which are used to store objects in the leaves.
*/
private _headA: LinkedList;
/**
* Refers to the internal A and B linked lists,
* which are used to store objects in the leaves.
*/
private _tailA: LinkedList;
/**
* Refers to the internal A and B linked lists,
* which are used to store objects in the leaves.
*/
private _headB: LinkedList;
/**
* Refers to the internal A and B linked lists,
* which are used to store objects in the leaves.
*/
private _tailB: LinkedList;
/**
* Internal, governs and assists with the formation of the tree.
*/
private static _min: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _northWestTree: QuadTree;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _northEastTree: QuadTree;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _southEastTree: QuadTree;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _southWestTree: QuadTree;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _leftEdge: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _rightEdge: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _topEdge: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _bottomEdge: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _halfWidth: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _halfHeight: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _midpointX: number;
/**
* Internal, governs and assists with the formation of the tree.
*/
private _midpointY: number;
/**
* Internal, used to reduce recursive method parameters during object placement and tree formation.
*/
private static _object;
/**
* Internal, used to reduce recursive method parameters during object placement and tree formation.
*/
private static _objectLeftEdge: number;
/**
* Internal, used to reduce recursive method parameters during object placement and tree formation.
*/
private static _objectTopEdge: number;
/**
* Internal, used to reduce recursive method parameters during object placement and tree formation.
*/
private static _objectRightEdge: number;
/**
* Internal, used to reduce recursive method parameters during object placement and tree formation.
*/
private static _objectBottomEdge: number;
/**
* Internal, used during tree processing and overlap checks.
*/
private static _list: number;
/**
* Internal, used during tree processing and overlap checks.
*/
private static _useBothLists: bool;
/**
* Internal, used during tree processing and overlap checks.
*/
private static _processingCallback;
/**
* Internal, used during tree processing and overlap checks.
*/
private static _notifyCallback;
/**
* Internal, used during tree processing and overlap checks.
*/
private static _iterator: LinkedList;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _objectHullX: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _objectHullY: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _objectHullWidth: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _objectHullHeight: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _checkObjectHullX: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _checkObjectHullY: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _checkObjectHullWidth: number;
/**
* Internal, helpers for comparing actual object-to-object overlap - see <code>overlapNode()</code>.
*/
private static _checkObjectHullHeight: number;
/**
* Clean up memory.
*/
public destroy() {
this._tailA.destroy();
this._tailB.destroy();
this._headA.destroy();
this._headB.destroy();
this._tailA = null;
this._tailB = null;
this._headA = null;
this._headB = null;
if (this._northWestTree != null)
{
this._northWestTree.destroy();
}
if (this._northEastTree != null)
{
this._northEastTree.destroy();
}
if (this._southEastTree != null)
{
this._southEastTree.destroy();
}
if (this._southWestTree != null)
{
this._southWestTree.destroy();
}
this._northWestTree = null;
this._northEastTree = null;
this._southEastTree = null;
this._southWestTree = null;
QuadTree._object = null;
QuadTree._processingCallback = null;
QuadTree._notifyCallback = null;
}
/**
* Load objects and/or groups into the quad tree, and register notify and processing callbacks.
*
* @param ObjectOrGroup1 Any object that is or extends GameObject or Group.
* @param ObjectOrGroup2 Any object that is or extends GameObject or Group. If null, the first parameter will be checked against itself.
* @param NotifyCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject)</code> that is called whenever two objects are found to overlap in world space, and either no ProcessCallback is specified, or the ProcessCallback returns true.
* @param ProcessCallback A function with the form <code>myFunction(Object1:GameObject,Object2:GameObject):bool</code> that is called whenever two objects are found to overlap in world space. The NotifyCallback is only called if this function returns true. See GameObject.separate().
*/
public load(ObjectOrGroup1: Basic, ObjectOrGroup2: Basic = null, NotifyCallback = null, ProcessCallback = null) {
//console.log('quadtree load', QuadTree.divisions, ObjectOrGroup1, ObjectOrGroup2);
this.add(ObjectOrGroup1, QuadTree.A_LIST);
if (ObjectOrGroup2 != null)
{
this.add(ObjectOrGroup2, QuadTree.B_LIST);
QuadTree._useBothLists = true;
}
else
{
QuadTree._useBothLists = false;
}
QuadTree._notifyCallback = NotifyCallback;
QuadTree._processingCallback = ProcessCallback;
//console.log('use both', QuadTree._useBothLists);
//console.log('------------ end of load');
}
/**
* Call this function to add an object to the root of the tree.
* This function will recursively add all group members, but
* not the groups themselves.
*
* @param ObjectOrGroup GameObjects are just added, Groups are recursed and their applicable members added accordingly.
* @param List A <code>uint</code> flag indicating the list to which you want to add the objects. Options are <code>QuadTree.A_LIST</code> and <code>QuadTree.B_LIST</code>.
*/
public add(ObjectOrGroup: Basic, List: number) {
QuadTree._list = List;
if (ObjectOrGroup.isGroup == true)
{
var i: number = 0;
var basic: Basic;
var members = <Group> ObjectOrGroup['members'];
var l: number = ObjectOrGroup['length'];
while (i < l)
{
basic = members[i++];
if ((basic != null) && basic.exists)
{
if (basic.isGroup)
{
this.add(basic, List);
}
else
{
QuadTree._object = basic;
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
{
QuadTree._objectLeftEdge = QuadTree._object.x;
QuadTree._objectTopEdge = QuadTree._object.y;
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
this.addObject();
}
}
}
}
}
else
{
QuadTree._object = ObjectOrGroup;
//console.log('add - not group:', ObjectOrGroup.name);
if (QuadTree._object.exists && QuadTree._object.allowCollisions)
{
QuadTree._objectLeftEdge = QuadTree._object.x;
QuadTree._objectTopEdge = QuadTree._object.y;
QuadTree._objectRightEdge = QuadTree._object.x + QuadTree._object.width;
QuadTree._objectBottomEdge = QuadTree._object.y + QuadTree._object.height;
//console.log('object properties', QuadTree._objectLeftEdge, QuadTree._objectTopEdge, QuadTree._objectRightEdge, QuadTree._objectBottomEdge);
this.addObject();
}
}
}
/**
* Internal function for recursively navigating and creating the tree
* while adding objects to the appropriate nodes.
*/
private addObject() {
//console.log('addObject');
//If this quad (not its children) lies entirely inside this object, add it here
if (!this._canSubdivide || ((this._leftEdge >= QuadTree._objectLeftEdge) && (this._rightEdge <= QuadTree._objectRightEdge) && (this._topEdge >= QuadTree._objectTopEdge) && (this._bottomEdge <= QuadTree._objectBottomEdge)))
{
//console.log('add To List');
this.addToList();
return;
}
//See if the selected object fits completely inside any of the quadrants
if ((QuadTree._objectLeftEdge > this._leftEdge) && (QuadTree._objectRightEdge < this._midpointX))
{
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
{
//console.log('Adding NW tree');
if (this._northWestTree == null)
{
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
}
this._northWestTree.addObject();
return;
}
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
{
//console.log('Adding SW tree');
if (this._southWestTree == null)
{
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
}
this._southWestTree.addObject();
return;
}
}
if ((QuadTree._objectLeftEdge > this._midpointX) && (QuadTree._objectRightEdge < this._rightEdge))
{
if ((QuadTree._objectTopEdge > this._topEdge) && (QuadTree._objectBottomEdge < this._midpointY))
{
//console.log('Adding NE tree');
if (this._northEastTree == null)
{
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
}
this._northEastTree.addObject();
return;
}
if ((QuadTree._objectTopEdge > this._midpointY) && (QuadTree._objectBottomEdge < this._bottomEdge))
{
//console.log('Adding SE tree');
if (this._southEastTree == null)
{
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
}
this._southEastTree.addObject();
return;
}
}
//If it wasn't completely contained we have to check out the partial overlaps
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
{
if (this._northWestTree == null)
{
this._northWestTree = new QuadTree(this._leftEdge, this._topEdge, this._halfWidth, this._halfHeight, this);
}
//console.log('added to north west partial tree');
this._northWestTree.addObject();
}
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._topEdge) && (QuadTree._objectTopEdge < this._midpointY))
{
if (this._northEastTree == null)
{
this._northEastTree = new QuadTree(this._midpointX, this._topEdge, this._halfWidth, this._halfHeight, this);
}
//console.log('added to north east partial tree');
this._northEastTree.addObject();
}
if ((QuadTree._objectRightEdge > this._midpointX) && (QuadTree._objectLeftEdge < this._rightEdge) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
{
if (this._southEastTree == null)
{
this._southEastTree = new QuadTree(this._midpointX, this._midpointY, this._halfWidth, this._halfHeight, this);
}
//console.log('added to south east partial tree');
this._southEastTree.addObject();
}
if ((QuadTree._objectRightEdge > this._leftEdge) && (QuadTree._objectLeftEdge < this._midpointX) && (QuadTree._objectBottomEdge > this._midpointY) && (QuadTree._objectTopEdge < this._bottomEdge))
{
if (this._southWestTree == null)
{
this._southWestTree = new QuadTree(this._leftEdge, this._midpointY, this._halfWidth, this._halfHeight, this);
}
//console.log('added to south west partial tree');
this._southWestTree.addObject();
}
}
/**
* Internal function for recursively adding objects to leaf lists.
*/
private addToList() {
//console.log('Adding to List');
var ot: LinkedList;
if (QuadTree._list == QuadTree.A_LIST)
{
//console.log('A LIST');
if (this._tailA.object != null)
{
ot = this._tailA;
this._tailA = new LinkedList();
ot.next = this._tailA;
}
this._tailA.object = QuadTree._object;
}
else
{
//console.log('B LIST');
if (this._tailB.object != null)
{
ot = this._tailB;
this._tailB = new LinkedList();
ot.next = this._tailB;
}
this._tailB.object = QuadTree._object;
}
if (!this._canSubdivide)
{
return;
}
if (this._northWestTree != null)
{
this._northWestTree.addToList();
}
if (this._northEastTree != null)
{
this._northEastTree.addToList();
}
if (this._southEastTree != null)
{
this._southEastTree.addToList();
}
if (this._southWestTree != null)
{
this._southWestTree.addToList();
}
}
/**
* <code>QuadTree</code>'s other main function. Call this after adding objects
* using <code>QuadTree.load()</code> to compare the objects that you loaded.
*
* @return Whether or not any overlaps were found.
*/
public execute(): bool {
//console.log('quadtree execute');
var overlapProcessed: bool = false;
var iterator: LinkedList;
if (this._headA.object != null)
{
//console.log('---------------------------------------------------');
//console.log('headA iterator');
iterator = this._headA;
while (iterator != null)
{
QuadTree._object = iterator.object;
if (QuadTree._useBothLists)
{
QuadTree._iterator = this._headB;
}
else
{
QuadTree._iterator = iterator.next;
}
if (QuadTree._object.exists && (QuadTree._object.allowCollisions > 0) && (QuadTree._iterator != null) && (QuadTree._iterator.object != null) && QuadTree._iterator.object.exists && this.overlapNode())
{
//console.log('headA iterator overlapped true');
overlapProcessed = true;
}
iterator = iterator.next;
}
}
//Advance through the tree by calling overlap on each child
if ((this._northWestTree != null) && this._northWestTree.execute())
{
//console.log('NW quadtree execute');
overlapProcessed = true;
}
if ((this._northEastTree != null) && this._northEastTree.execute())
{
//console.log('NE quadtree execute');
overlapProcessed = true;
}
if ((this._southEastTree != null) && this._southEastTree.execute())
{
//console.log('SE quadtree execute');
overlapProcessed = true;
}
if ((this._southWestTree != null) && this._southWestTree.execute())
{
//console.log('SW quadtree execute');
overlapProcessed = true;
}
return overlapProcessed;
}
/**
* An private for comparing an object against the contents of a node.
*
* @return Whether or not any overlaps were found.
*/
private overlapNode(): bool {
//Walk the list and check for overlaps
var overlapProcessed: bool = false;
var checkObject;
while (QuadTree._iterator != null)
{
if (!QuadTree._object.exists || (QuadTree._object.allowCollisions <= 0))
{
//console.log('break 1');
break;
}
checkObject = QuadTree._iterator.object;
if ((QuadTree._object === checkObject) || !checkObject.exists || (checkObject.allowCollisions <= 0))
{
//console.log('break 2');
QuadTree._iterator = QuadTree._iterator.next;
continue;
}
//calculate bulk hull for QuadTree._object
QuadTree._objectHullX = (QuadTree._object.x < QuadTree._object.last.x) ? QuadTree._object.x : QuadTree._object.last.x;
QuadTree._objectHullY = (QuadTree._object.y < QuadTree._object.last.y) ? QuadTree._object.y : QuadTree._object.last.y;
QuadTree._objectHullWidth = QuadTree._object.x - QuadTree._object.last.x;
QuadTree._objectHullWidth = QuadTree._object.width + ((QuadTree._objectHullWidth > 0) ? QuadTree._objectHullWidth : -QuadTree._objectHullWidth);
QuadTree._objectHullHeight = QuadTree._object.y - QuadTree._object.last.y;
QuadTree._objectHullHeight = QuadTree._object.height + ((QuadTree._objectHullHeight > 0) ? QuadTree._objectHullHeight : -QuadTree._objectHullHeight);
//calculate bulk hull for checkObject
QuadTree._checkObjectHullX = (checkObject.x < checkObject.last.x) ? checkObject.x : checkObject.last.x;
QuadTree._checkObjectHullY = (checkObject.y < checkObject.last.y) ? checkObject.y : checkObject.last.y;
QuadTree._checkObjectHullWidth = checkObject.x - checkObject.last.x;
QuadTree._checkObjectHullWidth = checkObject.width + ((QuadTree._checkObjectHullWidth > 0) ? QuadTree._checkObjectHullWidth : -QuadTree._checkObjectHullWidth);
QuadTree._checkObjectHullHeight = checkObject.y - checkObject.last.y;
QuadTree._checkObjectHullHeight = checkObject.height + ((QuadTree._checkObjectHullHeight > 0) ? QuadTree._checkObjectHullHeight : -QuadTree._checkObjectHullHeight);
//check for intersection of the two hulls
if ((QuadTree._objectHullX + QuadTree._objectHullWidth > QuadTree._checkObjectHullX) && (QuadTree._objectHullX < QuadTree._checkObjectHullX + QuadTree._checkObjectHullWidth) && (QuadTree._objectHullY + QuadTree._objectHullHeight > QuadTree._checkObjectHullY) && (QuadTree._objectHullY < QuadTree._checkObjectHullY + QuadTree._checkObjectHullHeight))
{
//console.log('intersection!');
//Execute callback functions if they exist
if ((QuadTree._processingCallback == null) || QuadTree._processingCallback(QuadTree._object, checkObject))
{
overlapProcessed = true;
}
if (overlapProcessed && (QuadTree._notifyCallback != null))
{
QuadTree._notifyCallback(QuadTree._object, checkObject);
}
}
QuadTree._iterator = QuadTree._iterator.next;
}
return overlapProcessed;
}
}
}
-26
View File
@@ -1,26 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class RandomDataGenerator {
constructor(seeds?: string[]);
private s0;
private s1;
private s2;
private c;
private uint32();
private fract32();
private rnd();
private hash(data);
public sow(seeds?: string[]): void;
public integer : number;
public frac : number;
public real : number;
public integerInRange(min: number, max: number): number;
public realInRange(min: number, max: number): number;
public normal : number;
public uuid : string;
public pick(array);
public weightedPick(array);
public timestamp(min?: number, max?: number): number;
public angle : number;
}
}
-20
View File
@@ -1,20 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class RequestAnimationFrame {
constructor(callback, callbackContext);
private _callback;
private _callbackContext;
public setCallback(callback): void;
private _timeOutID;
private _isSetTimeOut;
public isUsingSetTimeOut(): bool;
public isUsingRAF(): bool;
public lastTime: number;
public currentTime: number;
public isRunning: bool;
public start(callback?): void;
public stop(): void;
public RAFUpdate(): void;
public SetTimeoutUpdate(): void;
}
}
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="../SoundManager.d.ts" />
module Phaser {
class Sound {
constructor(context, gainNode, data, volume?: number, loop?: bool);
private _context;
private _gainNode;
private _localGainNode;
private _buffer;
private _volume;
private _sound;
public loop: bool;
public duration: number;
public isPlaying: bool;
public isDecoding: bool;
public setDecodedBuffer(data): void;
public play(): void;
public stop(): void;
public mute(): void;
public unmute(): void;
public volume : number;
}
}
-120
View File
@@ -1,120 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="../SoundManager.ts" />
/**
* Phaser - Sound
*
* A Sound file, used by the Game.SoundManager for playback.
*/
module Phaser {
export class Sound {
constructor(context, gainNode, data, volume?: number = 1, loop?: bool = false) {
this._context = context;
this._gainNode = gainNode;
this._buffer = data;
this._volume = volume;
this.loop = loop;
// Local volume control
if (this._context !== null)
{
this._localGainNode = this._context.createGainNode();
this._localGainNode.connect(this._gainNode);
this._localGainNode.gain.value = this._volume;
}
if (this._buffer === null)
{
this.isDecoding = true;
}
else
{
this.play();
}
}
private _context;
private _gainNode;
private _localGainNode;
private _buffer;
private _volume: number;
private _sound;
loop: bool = false;
duration: number;
isPlaying: bool = false;
isDecoding: bool = false;
public setDecodedBuffer(data) {
this._buffer = data;
this.isDecoding = false;
//this.play();
}
public play() {
if (this._buffer === null || this.isDecoding === true)
{
return;
}
this._sound = this._context.createBufferSource();
this._sound.buffer = this._buffer;
this._sound.connect(this._localGainNode);
if (this.loop)
{
this._sound.loop = true;
}
this._sound.noteOn(0); // the zero is vitally important, crashes iOS6 without it
this.duration = this._sound.buffer.duration;
this.isPlaying = true;
}
public stop() {
if (this.isPlaying === true)
{
this.isPlaying = false;
this._sound.noteOff(0);
}
}
public mute() {
this._localGainNode.gain.value = 0;
}
public unmute() {
this._localGainNode.gain.value = this._volume;
}
public set volume(value: number) {
this._volume = value;
this._localGainNode.gain.value = this._volume;
}
public get volume(): number {
return this._volume;
}
}
}
-21
View File
@@ -1,21 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class StageScaleMode {
constructor(game: Game);
private _game;
private _startHeight;
private _iterations;
private _check;
static EXACT_FIT: number;
static NO_SCALE: number;
static SHOW_ALL: number;
public width: number;
public height: number;
public orientation;
public update(): void;
public isLandscape : bool;
private checkOrientation(event);
private refresh();
private setScreenSize();
}
}
-169
View File
@@ -1,169 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - StageScaleMode
*
* This class controls the scaling of your game. On mobile devices it will also remove the URL bar and allow
* you to maintain proportion and aspect ratio.
* It is based on a technique taken from Viewporter v2.0 by Zynga Inc. http://github.com/zynga/viewporter
*/
module Phaser {
export class StageScaleMode {
constructor(game: Game) {
this._game = game;
this.orientation = window['orientation'];
window.addEventListener('orientationchange', (event) => this.checkOrientation(event), false);
}
private _game: Game;
private _startHeight: number = 0;
private _iterations: number;
private _check;
// Specifies that the game be visible in the specified area without trying to preserve the original aspect ratio.
public static EXACT_FIT: number = 0;
// Specifies that the size of the game be fixed, so that it remains unchanged even if the size of the window changes.
public static NO_SCALE: number = 1;
// Specifies that the entire game be visible in the specified area without distortion while maintaining the original aspect ratio.
public static SHOW_ALL: number = 2;
public width: number = 0;
public height: number = 0;
public orientation;
public update() {
if (this._game.stage.scaleMode !== StageScaleMode.NO_SCALE && (window.innerWidth !== this.width || window.innerHeight !== this.height))
{
this.refresh();
}
}
public get isLandscape(): bool {
return window['orientation'] === 90 || window['orientation'] === -90;
}
private checkOrientation(event) {
if (window['orientation'] !== this.orientation)
{
this.refresh();
this.orientation = window['orientation'];
}
}
private refresh() {
// We can't do anything about the status bars in iPads, web apps or desktops
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
{
document.documentElement.style.minHeight = '5000px';
this._startHeight = window.innerHeight;
if (this._game.device.android && this._game.device.chrome == false)
{
window.scrollTo(0, 1);
}
else
{
window.scrollTo(0, 0);
}
}
if (this._check == null)
{
this._iterations = 40;
this._check = window.setInterval(() => this.setScreenSize(), 10);
}
}
private setScreenSize() {
if (this._game.device.iPad == false && this._game.device.webApp == false && this._game.device.desktop == false)
{
if (this._game.device.android && this._game.device.chrome == false)
{
window.scrollTo(0, 1);
}
else
{
window.scrollTo(0, 0);
}
}
this._iterations--;
if (window.innerHeight > this._startHeight || this._iterations < 0)
{
// Set minimum height of content to new window height
document.documentElement.style.minHeight = window.innerHeight + 'px';
if (this._game.stage.scaleMode == StageScaleMode.EXACT_FIT)
{
if (this._game.stage.maxScaleX && window.innerWidth > this._game.stage.maxScaleX)
{
this.width = this._game.stage.maxScaleX;
}
else
{
this.width = window.innerWidth;
}
if (this._game.stage.maxScaleY && window.innerHeight > this._game.stage.maxScaleY)
{
this.height = this._game.stage.maxScaleY;
}
else
{
this.height = window.innerHeight;
}
}
else if (this._game.stage.scaleMode == StageScaleMode.SHOW_ALL)
{
var multiplier = Math.min((window.innerHeight / this._game.stage.height), (window.innerWidth / this._game.stage.width));
this.width = Math.round(this._game.stage.width * multiplier);
this.height = Math.round(this._game.stage.height * multiplier);
if (this._game.stage.maxScaleX && this.width > this._game.stage.maxScaleX)
{
this.width = this._game.stage.maxScaleX;
}
if (this._game.stage.maxScaleY && this.height > this._game.stage.maxScaleY)
{
this.height = this._game.stage.maxScaleY;
}
}
this._game.stage.canvas.style.width = this.width + 'px';
this._game.stage.canvas.style.height = this.height + 'px';
this._game.input.scaleX = this._game.stage.width / this.width;
this._game.input.scaleY = this._game.stage.height / this.height;
clearInterval(this._check);
this._check = null;
}
}
}
}
-22
View File
@@ -1,22 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class Tile {
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number);
private _game;
public name: string;
public mass: number;
public width: number;
public height: number;
public allowCollisions: number;
public collideLeft: bool;
public collideRight: bool;
public collideUp: bool;
public collideDown: bool;
public tilemap: Tilemap;
public index: number;
public destroy(): void;
public setCollision(collision: number, resetCollisions: bool): void;
public resetCollision(): void;
public toString(): string;
}
}
-131
View File
@@ -1,131 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - Tile
*
* A Tile is a single representation of a tile within a Tilemap
*/
module Phaser {
export class Tile {
constructor(game: Game, tilemap: Tilemap, index: number, width: number, height: number) {
this._game = game;
this.tilemap = tilemap;
this.index = index;
this.width = width;
this.height = height;
this.allowCollisions = Collision.NONE;
}
private _game: Game;
// You can give this Tile a friendly name to help with debugging. Never used internally.
public name: string;
public mass: number = 1.0;
public width: number;
public height: number;
public allowCollisions: number;
public collideLeft: bool = false;
public collideRight: bool = false;
public collideUp: bool = false;
public collideDown: bool = false;
public separateX: bool = true;
public separateY: bool = true;
/**
* A reference to the tilemap this tile object belongs to.
*/
public tilemap: Tilemap;
/**
* The index of this tile type in the core map data.
* For example, if your map only has 16 kinds of tiles in it,
* this number is usually between 0 and 15.
*/
public index: number;
/**
* Clean up memory.
*/
public destroy() {
this.tilemap = null;
}
public setCollision(collision: number, resetCollisions: bool, separateX: bool, separateY: bool) {
if (resetCollisions)
{
this.resetCollision();
}
this.separateX = separateX;
this.separateY = separateY;
this.allowCollisions = collision;
if (collision & Collision.ANY)
{
this.collideLeft = true;
this.collideRight = true;
this.collideUp = true;
this.collideDown = true;
return;
}
if (collision & Collision.LEFT || collision & Collision.WALL)
{
this.collideLeft = true;
}
if (collision & Collision.RIGHT || collision & Collision.WALL)
{
this.collideRight = true;
}
if (collision & Collision.UP || collision & Collision.CEILING)
{
this.collideUp = true;
}
if (collision & Collision.DOWN || collision & Collision.CEILING)
{
this.collideDown = true;
}
}
public resetCollision() {
this.allowCollisions = Collision.NONE;
this.collideLeft = false;
this.collideRight = false;
this.collideUp = false;
this.collideDown = false;
}
/**
* Returns a string representation of this object.
* @method toString
* @return {string} a string representation of the object.
**/
public toString(): string {
return "[{Tiled (index=" + this.index + " collisions=" + this.allowCollisions + " width=" + this.width + " height=" + this.height + ")}]";
}
}
}
-51
View File
@@ -1,51 +0,0 @@
/// <reference path="../Game.d.ts" />
module Phaser {
class TilemapLayer {
constructor(game: Game, parent: Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number);
private _game;
private _parent;
private _texture;
private _tileOffsets;
private _startX;
private _startY;
private _maxX;
private _maxY;
private _tx;
private _ty;
private _dx;
private _dy;
private _oldCameraX;
private _oldCameraY;
private _columnData;
private _tempTileX;
private _tempTileY;
private _tempTileW;
private _tempTileH;
public name: string;
public alpha: number;
public exists: bool;
public visible: bool;
public orientation: string;
public properties: {};
public mapData;
public mapFormat: number;
public boundsInTiles: Rectangle;
public tileWidth: number;
public tileHeight: number;
public widthInTiles: number;
public heightInTiles: number;
public widthInPixels: number;
public heightInPixels: number;
public tileMargin: number;
public tileSpacing: number;
public getTileFromWorldXY(x: number, y: number): number;
public getTileOverlaps(object: GameObject): bool;
public getTileBlock(x: number, y: number, width: number, height: number): any[];
public getTileIndex(x: number, y: number): number;
public addColumn(column): void;
public updateBounds(): void;
public parseTileOffsets(): number;
public renderDebugInfo(x: number, y: number, color?: string): void;
public render(camera: Camera, dx, dy): bool;
}
}
-456
View File
@@ -1,456 +0,0 @@
/// <reference path="../Game.ts" />
/**
* Phaser - TilemapLayer
*
* A Tilemap Layer. Tiled format maps can have multiple overlapping layers.
*/
module Phaser {
export class TilemapLayer {
constructor(game: Game, parent:Tilemap, key: string, mapFormat: number, name: string, tileWidth: number, tileHeight: number) {
this._game = game;
this._parent = parent;
this.name = name;
this.mapFormat = mapFormat;
this.tileWidth = tileWidth;
this.tileHeight = tileHeight;
this.boundsInTiles = new Rectangle();
//this.scrollFactor = new MicroPoint(1, 1);
this.mapData = [];
this._tempTileBlock = [];
this._texture = this._game.cache.getImage(key);
}
private _game: Game;
private _parent: Tilemap;
private _texture;
private _tileOffsets;
private _startX: number = 0;
private _startY: number = 0;
private _maxX: number = 0;
private _maxY: number = 0;
private _tx: number = 0;
private _ty: number = 0;
private _dx: number = 0;
private _dy: number = 0;
private _oldCameraX: number = 0;
private _oldCameraY: number = 0;
private _columnData;
private _tempTileX: number;
private _tempTileY: number;
private _tempTileW: number;
private _tempTileH: number;
private _tempTileBlock;
private _tempBlockResults;
public name: string;
public alpha: number = 1;
public exists: bool = true;
public visible: bool = true;
//public scrollFactor: MicroPoint;
public orientation: string;
public properties: {};
public mapData;
public mapFormat: number;
public boundsInTiles: Rectangle;
public tileWidth: number;
public tileHeight: number;
public widthInTiles: number = 0;
public heightInTiles: number = 0;
public widthInPixels: number = 0;
public heightInPixels: number = 0;
public tileMargin: number = 0;
public tileSpacing: number = 0;
public putTile(x: number, y: number, index: number) {
x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
if (y >= 0 && y < this.mapData.length)
{
if (x >= 0 && x < this.mapData[y].length)
{
this.mapData[y][x] = index;
}
}
}
public swapTile(tileA: number, tileB: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++)
{
// First sweep marking tileA as needing a new index
if (this._tempTileBlock[r].tile.index == tileA)
{
this._tempTileBlock[r].newIndex = true;
}
// In the same pass we can swap tileB to tileA
if (this._tempTileBlock[r].tile.index == tileB)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileA;
}
}
for (var r = 0; r < this._tempTileBlock.length; r++)
{
// And now swap our newIndex tiles for tileB
if (this._tempTileBlock[r].newIndex == true)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
}
}
}
public fillTile(index: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = index;
}
}
public randomiseTiles(tiles: number[], x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = this._game.math.getRandom(tiles);
}
}
public replaceTile(tileA: number, tileB: number, x?: number = 0, y?: number = 0, width?: number = this.widthInTiles, height?: number = this.heightInTiles) {
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++)
{
if (this._tempTileBlock[r].tile.index == tileA)
{
this.mapData[this._tempTileBlock[r].y][this._tempTileBlock[r].x] = tileB;
}
}
}
public getTileBlock(x: number, y: number, width: number, height: number) {
var output = [];
this.getTempBlock(x, y, width, height);
for (var r = 0; r < this._tempTileBlock.length; r++)
{
output.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
}
return output;
}
public getTileFromWorldXY(x: number, y: number): number {
x = this._game.math.snapToFloor(x, this.tileWidth) / this.tileWidth;
y = this._game.math.snapToFloor(y, this.tileHeight) / this.tileHeight;
return this.getTileIndex(x, y);
}
public getTileOverlaps(object: GameObject) {
// If the object is outside of the world coordinates then abort the check (tilemap has to exist within world bounds)
if (object.bounds.x < 0 || object.bounds.x > this.widthInPixels || object.bounds.y < 0 || object.bounds.bottom > this.heightInPixels)
{
return;
}
// What tiles do we need to check against?
this._tempTileX = this._game.math.snapToFloor(object.bounds.x, this.tileWidth) / this.tileWidth;
this._tempTileY = this._game.math.snapToFloor(object.bounds.y, this.tileHeight) / this.tileHeight;
this._tempTileW = (this._game.math.snapToCeil(object.bounds.width, this.tileWidth) + this.tileWidth) / this.tileWidth;
this._tempTileH = (this._game.math.snapToCeil(object.bounds.height, this.tileHeight) + this.tileHeight) / this.tileHeight;
// Loop through the tiles we've got and check overlaps accordingly (the results are stored in this._tempTileBlock)
this._tempBlockResults = [];
this.getTempBlock(this._tempTileX, this._tempTileY, this._tempTileW, this._tempTileH, true);
Collision.TILE_OVERLAP = false;
for (var r = 0; r < this._tempTileBlock.length; r++)
{
if (Collision.separateTile(object, this._tempTileBlock[r].x * this.tileWidth, this._tempTileBlock[r].y * this.tileHeight, this.tileWidth, this.tileHeight, this._tempTileBlock[r].tile.mass, this._tempTileBlock[r].tile.collideLeft, this._tempTileBlock[r].tile.collideRight, this._tempTileBlock[r].tile.collideUp, this._tempTileBlock[r].tile.collideDown, this._tempTileBlock[r].tile.separateX, this._tempTileBlock[r].tile.separateY) == true)
{
this._tempBlockResults.push({ x: this._tempTileBlock[r].x, y: this._tempTileBlock[r].y, tile: this._tempTileBlock[r].tile });
}
}
return this._tempBlockResults;
}
private getTempBlock(x: number, y: number, width: number, height: number, collisionOnly?: bool = false) {
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
if (width > this.widthInTiles)
{
width = this.widthInTiles;
}
if (height > this.heightInTiles)
{
height = this.heightInTiles;
}
this._tempTileBlock = [];
for (var ty = y; ty < y + height; ty++)
{
for (var tx = x; tx < x + width; tx++)
{
if (collisionOnly)
{
// We only want to consider the tile for checking if you can actually collide with it
if (this.mapData[ty] && this.mapData[ty][tx] && this._parent.tiles[this.mapData[ty][tx]].allowCollisions != Collision.NONE)
{
this._tempTileBlock.push({ x: tx, y: ty, tile: this._parent.tiles[this.mapData[ty][tx]] });
}
}
else
{
if (this.mapData[ty] && this.mapData[ty][tx])
{
this._tempTileBlock.push({ x: tx, y: ty, tile: this._parent.tiles[this.mapData[ty][tx]] });
}
}
}
}
}
public getTileIndex(x: number, y: number): number {
if (y >= 0 && y < this.mapData.length)
{
if (x >= 0 && x < this.mapData[y].length)
{
return this.mapData[y][x];
}
}
return null;
}
public addColumn(column) {
var data = [];
for (var c = 0; c < column.length; c++)
{
data[c] = parseInt(column[c]);
}
if (this.widthInTiles == 0)
{
this.widthInTiles = data.length;
this.widthInPixels = this.widthInTiles * this.tileWidth;
}
this.mapData.push(data);
this.heightInTiles++;
this.heightInPixels += this.tileHeight;
}
public updateBounds() {
this.boundsInTiles.setTo(0, 0, this.widthInTiles, this.heightInTiles);
}
public parseTileOffsets():number {
this._tileOffsets = [];
var i = 0;
if (this.mapFormat == Tilemap.FORMAT_TILED_JSON)
{
// For some reason Tiled counts from 1 not 0
this._tileOffsets[0] = null;
i = 1;
}
for (var ty = this.tileMargin; ty < this._texture.height; ty += (this.tileHeight + this.tileSpacing))
{
for (var tx = this.tileMargin; tx < this._texture.width; tx += (this.tileWidth + this.tileSpacing))
{
this._tileOffsets[i] = { x: tx, y: ty };
i++;
}
}
return this._tileOffsets.length;
}
public renderDebugInfo(x: number, y: number, color?: string = 'rgb(255,255,255)') {
this._game.stage.context.fillStyle = color;
this._game.stage.context.fillText('TilemapLayer: ' + this.name, x, y);
this._game.stage.context.fillText('startX: ' + this._startX + ' endX: ' + this._maxX, x, y + 14);
this._game.stage.context.fillText('startY: ' + this._startY + ' endY: ' + this._maxY, x, y + 28);
this._game.stage.context.fillText('dx: ' + this._dx + ' dy: ' + this._dy, x, y + 42);
}
public render(camera: Camera, dx, dy): bool {
if (this.visible === false || this.alpha < 0.1)
{
return false;
}
// Work out how many tiles we can fit into our camera and round it up for the edges
this._maxX = this._game.math.ceil(camera.width / this.tileWidth) + 1;
this._maxY = this._game.math.ceil(camera.height / this.tileHeight) + 1;
// And now work out where in the tilemap the camera actually is
this._startX = this._game.math.floor(camera.worldView.x / this.tileWidth);
this._startY = this._game.math.floor(camera.worldView.y / this.tileHeight);
// Tilemap bounds check
if (this._startX < 0)
{
this._startX = 0;
}
if (this._startY < 0)
{
this._startY = 0;
}
if (this._maxX > this.widthInTiles)
{
this._maxX = this.widthInTiles;
}
if (this._maxY > this.heightInTiles)
{
this._maxY = this.heightInTiles;
}
if (this._startX + this._maxX > this.widthInTiles)
{
this._startX = this.widthInTiles - this._maxX;
}
if (this._startY + this._maxY > this.heightInTiles)
{
this._startY = this.heightInTiles - this._maxY;
}
// Finally get the offset to avoid the blocky movement
this._dx = dx;
this._dy = dy;
this._dx += -(camera.worldView.x - (this._startX * this.tileWidth));
this._dy += -(camera.worldView.y - (this._startY * this.tileHeight));
this._tx = this._dx;
this._ty = this._dy;
// Apply camera difference
/*
if (this.scrollFactor.x !== 1.0 || this.scrollFactor.y !== 1.0)
{
this._dx -= (camera.worldView.x * this.scrollFactor.x);
this._dy -= (camera.worldView.y * this.scrollFactor.y);
}
*/
// Alpha
if (this.alpha !== 1)
{
var globalAlpha = this._game.stage.context.globalAlpha;
this._game.stage.context.globalAlpha = this.alpha;
}
for (var row = this._startY; row < this._startY + this._maxY; row++)
{
this._columnData = this.mapData[row];
for (var tile = this._startX; tile < this._startX + this._maxX; tile++)
{
if (this._tileOffsets[this._columnData[tile]])
{
this._game.stage.context.drawImage(
this._texture, // Source Image
this._tileOffsets[this._columnData[tile]].x, // Source X (location within the source image)
this._tileOffsets[this._columnData[tile]].y, // Source Y
this.tileWidth, // Source Width
this.tileHeight, // Source Height
this._tx, // Destination X (where on the canvas it'll be drawn)
this._ty, // Destination Y
this.tileWidth, // Destination Width (always same as Source Width unless scaled)
this.tileHeight // Destination Height (always same as Source Height unless scaled)
);
}
this._tx += this.tileWidth;
}
this._tx = this._dx;
this._ty += this.tileHeight;
}
if (globalAlpha > -1)
{
this._game.stage.context.globalAlpha = globalAlpha;
}
return true;
}
}
}
-42
View File
@@ -1,42 +0,0 @@
/// <reference path="../Game.d.ts" />
/// <reference path="easing/Back.d.ts" />
/// <reference path="easing/Bounce.d.ts" />
/// <reference path="easing/Circular.d.ts" />
/// <reference path="easing/Cubic.d.ts" />
/// <reference path="easing/Elastic.d.ts" />
/// <reference path="easing/Exponential.d.ts" />
/// <reference path="easing/Linear.d.ts" />
/// <reference path="easing/Quadratic.d.ts" />
/// <reference path="easing/Quartic.d.ts" />
/// <reference path="easing/Quintic.d.ts" />
/// <reference path="easing/Sinusoidal.d.ts" />
module Phaser {
class Tween {
constructor(object, game: Game);
private _game;
private _manager;
private _object;
private _pausedTime;
private _valuesStart;
private _valuesEnd;
private _duration;
private _delayTime;
private _startTime;
private _easingFunction;
private _interpolationFunction;
private _chainedTweens;
public onStart: Signal;
public onUpdate: Signal;
public onComplete: Signal;
public to(properties, duration?: number, ease?: any, autoStart?: bool): Tween;
public start(): Tween;
public stop(): Tween;
public parent : Game;
public delay : number;
public easing : any;
public interpolation : any;
public chain(tween: Tween): Tween;
public debugValue;
public update(time): bool;
}
}
-239
View File
@@ -1,239 +0,0 @@
/// <reference path="../Game.ts" />
/// <reference path="easing/Back.ts" />
/// <reference path="easing/Bounce.ts" />
/// <reference path="easing/Circular.ts" />
/// <reference path="easing/Cubic.ts" />
/// <reference path="easing/Elastic.ts" />
/// <reference path="easing/Exponential.ts" />
/// <reference path="easing/Linear.ts" />
/// <reference path="easing/Quadratic.ts" />
/// <reference path="easing/Quartic.ts" />
/// <reference path="easing/Quintic.ts" />
/// <reference path="easing/Sinusoidal.ts" />
/**
* Phaser - Tween
*
* Based heavily on tween.js by sole (https://github.com/sole/tween.js) converted to TypeScript and integrated into Phaser
*/
module Phaser {
export class Tween {
constructor(object, game:Phaser.Game) {
this._object = object;
this._game = game;
this._manager = this._game.tweens;
this._interpolationFunction = this._game.math.linearInterpolation;
this._easingFunction = Phaser.Easing.Linear.None;
this._chainedTweens = [];
this.onStart = new Phaser.Signal();
this.onUpdate = new Phaser.Signal();
this.onComplete = new Phaser.Signal();
}
private _game: Phaser.Game;
private _manager: Phaser.TweenManager;
private _object = null;
private _pausedTime: number = 0;
private _valuesStart = {};
private _valuesEnd = {};
private _duration = 1000;
private _delayTime = 0;
private _startTime = null;
private _easingFunction;
private _interpolationFunction;
private _chainedTweens = [];
public onStart: Phaser.Signal;
public onUpdate: Phaser.Signal;
public onComplete: Phaser.Signal;
public to(properties, duration?: number = 1000, ease?: any = null, autoStart?: bool = false) {
this._duration = duration;
// If properties isn't an object this will fail, sanity check it here somehow?
this._valuesEnd = properties;
if (ease !== null)
{
this._easingFunction = ease;
}
if (autoStart === true)
{
return this.start();
}
else
{
return this;
}
}
public start() {
if (this._game === null || this._object === null)
{
return;
}
this._manager.add(this);
this.onStart.dispatch(this._object);
this._startTime = this._game.time.now + this._delayTime;
for (var property in this._valuesEnd)
{
// This prevents the interpolation of null values or of non-existing properties
if (this._object[property] === null || !(property in this._object))
{
throw Error('Phaser.Tween interpolation of null value of non-existing property');
continue;
}
// check if an Array was provided as property value
if (this._valuesEnd[property] instanceof Array)
{
if (this._valuesEnd[property].length === 0)
{
continue;
}
// create a local copy of the Array with the start value at the front
this._valuesEnd[property] = [this._object[property]].concat(this._valuesEnd[property]);
}
this._valuesStart[property] = this._object[property];
}
return this;
}
public stop() {
if (this._manager !== null)
{
this._manager.remove(this);
}
this.onComplete.dispose();
return this;
}
public set parent(value:Phaser.Game) {
this._game = value;
this._manager = this._game.tweens;
}
public set delay(amount:number) {
this._delayTime = amount;
}
public get delay(): number {
return this._delayTime;
}
public set easing(easing) {
this._easingFunction = easing;
}
public get easing():any {
return this._easingFunction;
}
public set interpolation(interpolation) {
this._interpolationFunction = interpolation;
}
public get interpolation():any {
return this._interpolationFunction;
}
public chain(tween:Phaser.Tween) {
this._chainedTweens.push(tween);
return this;
}
public debugValue;
public update(time) {
if (this._game.paused == true)
{
if (this._pausedTime == 0)
{
this._pausedTime = time;
}
}
else
{
// Ok we aren't paused, but was there some time gained?
if (this._pausedTime > 0)
{
this._startTime += (time - this._pausedTime);
this._pausedTime = 0;
}
}
if (time < this._startTime)
{
return true;
}
var elapsed = (time - this._startTime) / this._duration;
elapsed = elapsed > 1 ? 1 : elapsed;
var value = this._easingFunction(elapsed);
for (var property in this._valuesStart)
{
// Add checks for object, array, numeric up front
if (this._valuesEnd[property] instanceof Array)
{
this._object[property] = this._interpolationFunction(this._valuesEnd[property], value);
}
else
{
this._object[property] = this._valuesStart[property] + (this._valuesEnd[property] - this._valuesStart[property]) * value;
}
}
this.onUpdate.dispatch(this._object, value);
if (elapsed == 1)
{
this.onComplete.dispatch(this._object);
for (var i = 0; i < this._chainedTweens.length; i++)
{
this._chainedTweens[i].start();
}
return false;
}
return true;
}
}
}
-27
View File
@@ -1,27 +0,0 @@
/// <reference path="../../Game.d.ts" />
module Phaser {
class Animation {
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool);
private _game;
private _parent;
private _frames;
private _frameData;
private _frameIndex;
private _timeLastFrame;
private _timeNextFrame;
public name: string;
public currentFrame: Frame;
public isFinished: bool;
public isPlaying: bool;
public looped: bool;
public delay: number;
public frameTotal : number;
public frame : number;
public play(frameRate?: number, loop?: bool): void;
public restart(): void;
public stop(): void;
public update(): bool;
public destroy(): void;
private onComplete();
}
}
-167
View File
@@ -1,167 +0,0 @@
/// <reference path="../../Game.ts" />
/**
* Phaser - Animation
*
* An Animation is a single animation. It is created by the AnimationManager and belongs to Sprite objects.
*/
module Phaser {
export class Animation {
constructor(game: Game, parent: Sprite, frameData: FrameData, name: string, frames, delay: number, looped: bool) {
this._game = game;
this._parent = parent;
this._frames = frames;
this._frameData = frameData;
this.name = name;
this.delay = 1000 / delay;
this.looped = looped;
this.isFinished = false;
this.isPlaying = false;
this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
private _game: Game;
private _parent: Sprite;
private _frames: number[];
private _frameData: FrameData;
private _frameIndex: number;
private _timeLastFrame: number;
private _timeNextFrame: number;
public name: string;
public currentFrame: Frame;
public isFinished: bool;
public isPlaying: bool;
public looped: bool;
public delay: number;
public get frameTotal(): number {
return this._frames.length;
}
public get frame(): number {
return this._frameIndex;
}
public set frame(value: number) {
this.currentFrame = this._frameData.getFrame(value);
if (this.currentFrame !== null)
{
this._parent.bounds.width = this.currentFrame.width;
this._parent.bounds.height = this.currentFrame.height;
this._frameIndex = value;
}
}
public play(frameRate?: number = null, loop?: bool) {
if (frameRate !== null)
{
this.delay = 1000 / frameRate;
}
if (loop !== undefined)
{
this.looped = loop;
}
this.isPlaying = true;
this.isFinished = false;
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
public restart() {
this.isPlaying = true;
this.isFinished = false;
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
public stop() {
this.isPlaying = false;
this.isFinished = true;
}
public update(): bool {
if (this.isPlaying == true && this._game.time.now >= this._timeNextFrame)
{
this._frameIndex++;
if (this._frameIndex == this._frames.length)
{
if (this.looped)
{
this._frameIndex = 0;
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
else
{
this.onComplete();
}
}
else
{
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
}
this._timeLastFrame = this._game.time.now;
this._timeNextFrame = this._game.time.now + this.delay;
return true;
}
return false;
}
public destroy() {
this._game = null;
this._parent = null;
this._frames = null;
this._frameData = null;
this.currentFrame = null;
this.isPlaying = false;
}
private onComplete() {
this.isPlaying = false;
this.isFinished = true;
// callback
}
}
}
-7
View File
@@ -1,7 +0,0 @@
/// <reference path="../../Game.d.ts" />
module Phaser {
class AnimationLoader {
static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData;
static parseJSONData(game: Game, json): FrameData;
}
}
@@ -1,88 +0,0 @@
/// <reference path="../../Game.ts" />
/**
* Phaser - AnimationLoader
*
* Responsible for parsing sprite sheet and JSON data into the internal FrameData format that Phaser uses for animations.
*/
module Phaser {
export class AnimationLoader {
public static parseSpriteSheet(game: Game, key: string, frameWidth: number, frameHeight: number, frameMax: number): FrameData {
// How big is our image?
var img = game.cache.getImage(key);
if (img == null)
{
return null;
}
var width = img.width;
var height = img.height;
var row = Math.round(width / frameWidth);
var column = Math.round(height / frameHeight);
var total = row * column;
if (frameMax !== -1)
{
total = frameMax;
}
// Zero or smaller than frame sizes?
if (width == 0 || height == 0 || width < frameWidth || height < frameHeight || total === 0)
{
return null;
}
// Let's create some frames then
var data: FrameData = new FrameData();
var x = 0;
var y = 0;
for (var i = 0; i < total; i++)
{
data.addFrame(new Frame(x, y, frameWidth, frameHeight, ''));
x += frameWidth;
if (x === width)
{
x = 0;
y += frameHeight;
}
}
return data;
}
public static parseJSONData(game: Game, json): FrameData {
// Let's create some frames then
var data: FrameData = new FrameData();
// By this stage frames is a fully parsed array
var frames = json;
var newFrame: Frame;
for (var i = 0; i < frames.length; i++)
{
newFrame = data.addFrame(new Frame(frames[i].frame.x, frames[i].frame.y, frames[i].frame.w, frames[i].frame.h, frames[i].filename));
newFrame.setTrim(frames[i].trimmed, frames[i].sourceSize.w, frames[i].sourceSize.h, frames[i].spriteSourceSize.x, frames[i].spriteSourceSize.y, frames[i].spriteSourceSize.w, frames[i].spriteSourceSize.h);
}
return data;
}
}
}
-23
View File
@@ -1,23 +0,0 @@
/// <reference path="../../Game.d.ts" />
module Phaser {
class Frame {
constructor(x: number, y: number, width: number, height: number, name: string);
public x: number;
public y: number;
public width: number;
public height: number;
public index: number;
public name: string;
public rotated: bool;
public rotationDirection: string;
public trimmed: bool;
public sourceSizeW: number;
public sourceSizeH: number;
public spriteSourceSizeX: number;
public spriteSourceSizeY: number;
public spriteSourceSizeW: number;
public spriteSourceSizeH: number;
public setRotation(rotated: bool, rotationDirection: string): void;
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight): void;
}
}
-74
View File
@@ -1,74 +0,0 @@
/// <reference path="../../Game.ts" />
/**
* Phaser - Frame
*
* A Frame is a single frame of an animation and is part of a FrameData collection.
*/
module Phaser {
export class Frame {
constructor(x: number, y: number, width: number, height: number, name: string) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.name = name;
this.rotated = false;
this.trimmed = false;
}
// Position within the image to cut from
public x: number;
public y: number;
public width: number;
public height: number;
// Useful for Sprite Sheets
public index: number;
// Useful for Texture Atlas files (is set to the filename value)
public name: string = '';
// Rotated? (not yet implemented)
public rotated: bool = false;
// Either cw or ccw, rotation is always 90 degrees
public rotationDirection: string = 'cw';
// Was it trimmed when packed?
public trimmed: bool;
// The coordinates of the trimmed sprite inside the original sprite
public sourceSizeW: number;
public sourceSizeH: number;
public spriteSourceSizeX: number;
public spriteSourceSizeY: number;
public spriteSourceSizeW: number;
public spriteSourceSizeH: number;
public setRotation(rotated: bool, rotationDirection: string) {
// Not yet supported
}
public setTrim(trimmed: bool, actualWidth, actualHeight, destX, destY, destWidth, destHeight, ) {
this.trimmed = trimmed;
this.sourceSizeW = actualWidth;
this.sourceSizeH = actualHeight;
this.spriteSourceSizeX = destX;
this.spriteSourceSizeY = destY;
this.spriteSourceSizeW = destWidth;
this.spriteSourceSizeH = destHeight;
}
}
}
-18
View File
@@ -1,18 +0,0 @@
/// <reference path="../../Game.d.ts" />
module Phaser {
class FrameData {
constructor();
private _frames;
private _frameNames;
public total : number;
public addFrame(frame: Frame): Frame;
public getFrame(index: number): Frame;
public getFrameByName(name: string): Frame;
public checkFrameName(name: string): bool;
public getFrameRange(start: number, end: number, output?: Frame[]): Frame[];
public getFrameIndexes(output?: number[]): number[];
public getFrameIndexesByName(input: string[]): number[];
public getAllFrames(): Frame[];
public getFrames(range: number[]): Frame[];
}
}
-134
View File
@@ -1,134 +0,0 @@
/// <reference path="../../Game.ts" />
/**
* Phaser - FrameData
*
* FrameData is a container for Frame objects, the internal representation of animation data in Phaser.
*/
module Phaser {
export class FrameData {
constructor() {
this._frames = [];
this._frameNames = [];
}
private _frames: Frame[];
private _frameNames;
public get total(): number {
return this._frames.length;
}
public addFrame(frame: Frame): Frame {
frame.index = this._frames.length;
this._frames.push(frame);
if (frame.name !== '')
{
this._frameNames[frame.name] = frame.index;
}
return frame;
}
public getFrame(index: number): Frame {
if (this._frames[index])
{
return this._frames[index];
}
return null;
}
public getFrameByName(name: string): Frame {
if (this._frameNames[name] >= 0)
{
return this._frames[this._frameNames[name]];
}
return null;
}
public checkFrameName(name: string): bool {
if (this._frameNames[name] >= 0)
{
return true;
}
return false;
}
public getFrameRange(start: number, end: number, output?: Frame[] = []): Frame[] {
for (var i = start; i <= end; i++)
{
output.push(this._frames[i]);
}
return output;
}
public getFrameIndexes(output?: number[] = []): number[] {
output.length = 0;
for (var i = 0; i < this._frames.length; i++)
{
output.push(i);
}
return output;
}
public getFrameIndexesByName(input: string[]): number[] {
var output: number[] = [];
for (var i = 0; i < input.length; i++)
{
if (this.getFrameByName(input[i]))
{
output.push(this.getFrameByName(input[i]).index);
}
}
return output;
}
public getAllFrames(): Frame[] {
return this._frames;
}
public getFrames(range: number[]) {
var output: Frame[] = [];
for (var i = 0; i < range.length; i++)
{
output.push(this._frames[i]);
}
return output;
}
}
}

Some files were not shown because too many files have changed in this diff Show More