Weapon.fire has two new arguments: `offsetX` and `offsetY`. If the bullet is fired from a tracked Sprite or Pointer, or the `from` argument is set, this applies a horizontal and vertical offset from the launch position.
Weapon.fireOffset attempts to fire a single Bullet from a tracked Sprite or Pointer, but applies an offset to the position first. This is a shorter form of calling `Weapon.fire` and passing in the offset arguments.
Weapon.fireMany attempts to fire multiple bullets from the positions defined in the given array. If you provide a `from` argument, or if there is a tracked Sprite or Pointer, then the positions are treated as __offsets__ from the given objects position. If `from` is undefined, and there is no tracked object, then the bullets are fired from the given positions, as they exist in the world.
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.
* 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!
Groups have a new method `alignIn`. It allows you to align the Group within another Game Object, or a Rectangle. You can specify one of 9 positions which are the new position constants such as: `Phaser.TOP_LEFT` or `Phaser.CENTER` (see docs for the complete list). The Groups are positioned based on their child bounds, which takes rotation and scaling into consideration. You can easily place Groups into the corners of the screen, or game world, or align them within other Sprites, using this method.
Groups have a new method `alignTo`. It allows you to align a Group to the side of another Game Object, or a Rectangle. You can specify one of 11 positions which are the new position constants such as: `Phaser.TOP_LEFT` or `Phaser.LEFT_BOTTOM` (see docs for the complete list). The Groups are positioned based on their child bounds, which takes rotation and scaling into consideration. You can easily align Groups next to other Sprites using this method.
ArcadePhysics.Body.onOverlap is a new Signal that is dispatched whenever the Body overlaps with another Body. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal: `sprite.body.onOverlap = new Phaser.Signal()` and it will be called when an overlap happens, passing two arguments: the sprites which collided.
ArcadePhysics.World.separateCircle is a new method that handles all circular body collisions internally within Arcade Physics (thanks @VitaZheltyakov)
All of the Arcade Physics internal methods, such as `collideGroupVsSelf`, `collideSpriteVsSprite` and so on, have been updated to work with circular body shapes (thanks @VitaZheltyakov)
ArcadePhysics.Body.onWorldBounds is a new Signal that is dispatched whenever the Body collides with the world bounds, something that was previously difficult to detect. Due to the potentially high volume of signals this could create it is disabled by default. To use this feature set this property to a Phaser.Signal: `sprite.body.onWorldBounds = new Phaser.Signal()` and it will be called when a collision happens, passing one argument: the sprite on which it occurred.