mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
4f21e70852
With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it. |
||
---|---|---|
.. | ||
box2d.d.ts | ||
p2.d.ts | ||
phaser.comments.d.ts | ||
phaser.d.ts | ||
phaser_box2d.d.ts | ||
pixi.comments.d.ts | ||
pixi.d.ts | ||
readme.md | ||
tslint.json | ||
typings.json |
TypeScript Definitions
Reference the phaser.d.ts
in your project.
Please use TypeScript 1.4+
phaser.d.ts
contains a reference topixi.d.ts
andp2.d.ts
and so both these files must remain siblings in the same directory.pixi.d.ts
has deviated from the official project. If you are a pixi user, pick up the ball over at the official pixi typescript repo.
Including typescript definitions in your project using Typings
You can now use typings, the TypeScript Definition Manager, to include Phaser's typescript definitions in your project:
- Make sure that typings is installed in your system:
npm install -g typings
- Install phaser typescript definitions as a global dependency:
typings install github:photonstorm/phaser/typescript/typings.json -GD
This will make phaser typescript definitions available for your compiler so that there is no need to reference them from your source files. For more information, check the official typings site.
Contributing
If you find any mistakes in these definitions or you feel they can be improved in any way, please make a pull request against the dev branch.
Note
Creature
defs are not yet provided.
The Box2D defs come from https://github.com/SBCGames/Phaser-Box2D-Typescript-defs