Commit graph

22 commits

Author SHA1 Message Date
Filip Nedyalkov
4f21e70852 Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds
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.
2016-07-21 02:14:10 +03:00
Filip Nedyalkov
483a3b6836 Fix for DisplayObject/DisplayObjectContainer - getting dimensions or bounds do NOT retrieve proper values
* Documentation
* TypeScript Defs
* Nothing, it's a bug fix

Describe the changes below:
I noticed that getting dimensions or bounds changed in Phaser 2.6.1 and
it was bugged - returned dimensions were doubled in the direction of the
scaling for example, but the nice thing was that this time the
dimensions included the rotation of the object - which I think should be
the default behavior. It also bugged getLocalBounds which started
returning global getBounds();
When I checked the previous version of phaser 2.5.0 - total different
story. getLocalBounds returns the object without any transformations to
it. Getting width and height works ok, but rotation wasn't calculated to
the dimensions at all.
In all cases only getBounds returned proper dimensions, which is
obviously not enough and this is also a very important issue to be
resolved as soon as possible since it's a major core component feature
used all the time.
That's why I decided to spare the time and hopefully find a good fix for
all of this mess and I think I finally got there and tried to make the
changes as much as possible with your Code of Conduct. This is actually
the first time I am requesting a pull so I hope it will do some good. I
did compare my results with how Flash handles dimensions - they match,
so I do hope I didn't miss something and believe you guys would make
sure everything works ok.
To help you with reviewing and possibly (and hopefully) accepting this
pull request I've made available online 3 demos of the issues and with
demo of the fix of course:
1.
http://www.nedyalkov.net/filip/demos/phaser/IncorrectDisplayObjectDimensionsDemo_v2.5.0/
2.
http://www.nedyalkov.net/filip/demos/phaser/IncorrectDisplayObjectDimensionsDemo_v2.6.1/
3.
http://www.nedyalkov.net/filip/demos/phaser/IncorrectDisplayObjectDimensionsDemoFixed_v2.6.1/

Here is a zip file of the demo projects (build with VS2015):

http://www.nedyalkov.net/filip/demos/phaser/IncorrectDisplayObjectDimensionsDemos.zip

I really hope to see this FIX in the next version - would help me and a
lot of people I guess to get the job done properly!

Thank you!
2016-07-18 02:32:29 +03:00
photonstorm
fced3f86ec Phaser 2.6.0 Release. 2016-07-08 15:46:26 +01:00
photonstorm
7ebae00c8f Phaser 2.5.1 RC1 2016-07-01 16:57:36 +01:00
Richard Davey
a9976d2703 Phaser 2.5.0 Release. 2016-06-17 12:46:56 +01:00
photonstorm
694debe94b Rebuilt Phaser Comments TypeScript defs. 2016-06-17 02:28:57 +01:00
photonstorm
47f0224a40 Phaser 2.4.9 release. 2016-06-17 01:11:24 +01:00
photonstorm
28c1a26780 Phaser 2.4.9 RC3. 2016-06-09 17:13:31 +01:00
photonstorm
aa8e5f00db Phaser 2.4.9 RC2. 2016-06-03 18:48:34 +01:00
photonstorm
9f28d0659d Phaser 2.4.8 release. 2016-05-19 12:36:51 +01:00
stafford
e6b9ca4e22 fix generateTexture return type 2016-05-12 15:30:33 +10:00
photonstorm
a29cc64932 Phaser 2.4.7 Final. 2016-04-22 15:15:28 +01:00
photonstorm
47123c192d 2.4.6 Build files + docs + TS Docs. 2016-02-18 14:41:53 +00:00
vulvulune
02a56316c3 Force the usage of typescript 1.4.1
Force the usage of typescript 1.4.1 because with higher versions the
generation of commented files failed. Refresh comments.d.ts files.
2015-11-09 09:53:34 +01:00
photonstorm
486c15f16f New docs. 2015-08-24 15:43:45 +01:00
photonstorm
858ad51610 Phaser 2.4 release. 2015-07-22 15:31:30 +01:00
photonstorm
f23ab1f3a9 TypeScript defs with comments update. 2015-03-26 02:59:11 +00:00
vulvulune
0c8b5f447f Improve d.ts comments generation
Add trimright in the comments, because there are a lot of comments with
useless whitespaces.
2015-01-21 12:05:35 +01:00
vulvulune
6c7da59565 Improve d.ts comments generation
Remove empty @returns.
2015-01-21 11:54:16 +01:00
vulvulune
af1345c39e Improve d.ts comments generation
-Improve the script to clean the different kinds of end of line
-Improve the alignement with @return multiline comments
-Add a jsdoc plugin to convert the class name of p2.js file, like this
the comments for the p2 classes are now included in the d.ts files.
2015-01-21 11:42:56 +01:00
vulvulune
a5fde63486 Improve d.ts comments generation
- Remove " - " after @param paramname, and @return because it is
useless.
- Improve alignement of multiline param comments.
2015-01-21 08:50:14 +01:00
vulvulune
df6b946ceb Add grunt task to generate d.ts with comments
Add "tsdocs" grunt task to generate d.ts files with comments.
2015-01-20 17:18:56 +01:00