Commit graph

334 commits

Author SHA1 Message Date
photonstorm
b0f27b3f3c Color.hexToRGBArray converts a hex color value to an [R, G, B] array.
Color.RGBArrayToHex converts an RGB color array, in the format: [R, G, B], to a hex color value.
2016-09-28 13:57:29 +01:00
photonstorm
eda4961c06 Math.getNextPowerOfTwo will get the next power of two for the given value.
Math.isPowerOfTwo will return a boolean if the given width and height are a power of two.
2016-09-28 13:48:08 +01:00
photonstorm
bffdb8fbc5 Moved the Canvas tests into the Phaser.Device class. 2016-09-28 13:39:30 +01:00
Richard Davey
0bfb52d159 Phaser.SpriteBatch was incorrectly applying the prototypes, causing the Sprite Batch render methods to be replaced by the normal DisplayObjectContainer ones, meaning nothing was really batched at all. This has now been fixed, and PIXI.SpriteBatch removed, as it's no longer required. 2016-09-28 00:43:19 +01:00
Richard Davey
1c415a0d7e Cache.addBitmapFontFromAtlas allows you to add a Bitmap Font to the Cache, that is comprised of a frame from a Texture Atlas, and the font data (in JSON or XML format). Once added you can use the Bitmap Font in the same way as you would any Bitmap Font (#2614) 2016-09-27 02:00:31 +01:00
Richard Davey
811c347cc3 Camera.fade has a new argument alpha to control the alpha level of the effect (thanks @rgk #2493)
Camera.flash has a new argument `alpha` to control the alpha level of the effect (thanks @rgk #2493)
2016-09-27 01:07:40 +01:00
Richard Davey
f331697fee Text.splitRegExp is a new property that allows you to control the regular expression that is used to split the text into multiple lines (@dai-shi #1403) 2016-09-26 22:35:54 +01:00
Richard Davey
604da9ebc8 TS defs fix #2754 2016-09-26 21:28:43 +01:00
Richard Davey
de56e37400 Merge pull request #2760 from JTronLabs/dev
Phaser.Math.between fixes & added Phaser.Math.random
2016-09-26 20:55:05 +01:00
Richard Davey
53de7c20f0 Small code tidy + TS defs for #2763 2016-09-26 20:49:35 +01:00
Richard Davey
665f126461 Updated docs and defs. 2016-09-21 23:10:46 +01:00
Richard Davey
fb1ea7a01e Updated documentation. 2016-09-21 22:59:20 +01:00
Richard Davey
6aff35b5fd Frame.rotationDirection has been removed. It isn't needed, as modern texture packers only rotate 90 degrees clockwise anyway, and Phaser only supports this rotation direction. 2016-09-21 22:53:30 +01:00
Richard Davey
f3c5b7a0bc TS defs update. 2016-09-20 02:03:00 +01:00
Richard Davey
6fd15ee0e5 Updated TS defs for multi-texture support. 2016-09-20 00:21:24 +01:00
James Lowrey
b41d2453a9 TS defs 2016-09-14 18:34:16 -07:00
Richard Davey
b1473c55b9 Defs update #2737 2016-09-08 01:46:54 +01:00
Richard Davey
17f8181338 Defs update #2747 2016-09-08 01:44:53 +01:00
Richard Davey
c42c447bfb Weapon.multiFire is a new property that allows you to set a Weapon as being allowed to call fire as many times as you like, per game loop. This allows a single Weapon instance to fire multiple bullets.
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.
2016-09-08 01:42:19 +01:00
Christiano Teixeira
5ef9e8a24b Fixing the return type in typings for BitmapData.getPixel 2016-08-27 15:28:40 -03:00
Richard Davey
dd39f9ab08 Updated TS defs. 2016-08-26 01:24:15 +01:00
James
e90619b40e changed return value of Plugin.Weapon's fire, fireAtXY, fireAtPointer, fireAtSprite to Phaser.Bullet 2016-08-17 18:24:24 -05:00
Richard Davey
63ce6ae6c4 Defs update #2689 2016-08-16 21:01:41 +01:00
Filip Nedyalkov
a3502ebb4f updated the comment for getLocalBounds() in the typescript definitions. 2016-07-28 21:47:21 +03:00
Richard Davey
19e609185a Math.rotateToAngle takes two angles (in radians), and an interpolation value, and returns a new angle, based on the shortest rotational distance between the two. 2016-07-25 00:39:38 +01:00
Richard Davey
fb1a7f13cb Merge pull request #2639 from fmflame/display-object-container-dimensions-fix
Fix for DisplayObject/DisplayObjectContainer - getting dimensions or bounds do NOT retrieve proper values
2016-07-23 12:18:06 +01:00
Richard Davey
6947057427 The property checkCollision.none in the ArcadePhysics.Body class was available, but never used internally. It is now used and checked by the separate method. By setting checkCollision.none = true you can disable all collision and overlap checks on a Body, but still retain its motion updates (thanks @samme #2661) 2016-07-23 10:01:38 +01:00
Richard Davey
46c20ab00a The property checkCollision.none has been removed from the ArcadePhysics.Body class. It was never used internally, so lead to confusion about its use. To disable a body, use body.enable = false (thanks @samme #2661) 2016-07-23 09:43:01 +01:00
Richard Davey
d14250304c Defs update. 2016-07-22 04:19:17 +01:00
Richard Davey
9eff79f2c2 Phaser.Tileset has a new property lastgid which is populated automatically by the TilemapParser when importing Tiled map data, or can be set manually if building your own tileset. 2016-07-22 02:35:33 +01:00
Richard Davey
c36babcc1c Code formatting and docs updates. 2016-07-21 10:45:23 +01:00
Richard Davey
79e135087f ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use. 2016-07-21 02:11:16 +01:00
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
Richard Davey
60b8d78ab8 Group.align updates. 2016-07-20 12:29:30 +01:00
Richard Davey
bd6c91f924 Merge pull request #2651 from calvindavis/dev
Fixed optional seeds parameter in RandomDataGenerator's constructor.
2016-07-20 12:11:17 +01:00
Calvin Davis
e12e34e56d Fixed optional seeds parameter in RandomDataGenerator's constructor. 2016-07-19 16:18:48 +01:00
Richard Davey
b2c0b3d014 Merge pull request #2641 from calvindavis/dev
Fixed optional alpha parameter in interpolateColor.
2016-07-18 18:22:15 +01:00
Richard Davey
e62257fbed Merge pull request #2640 from Amyantis/physicsGroup_definition_fix
Fix definition of GameObjectFactory.physicsGroup
2016-07-18 18:21:46 +01:00
Calvin Davis
c2d596997c Fixed optional alpha parameter in interpolateColor. 2016-07-18 17:21:02 +01: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
Richard Davey
8d914bece8 Fixed TS defs for weapon.fire. 2016-07-16 07:56:16 +01:00
Amyantis
8b386dbbb1 Fix definition of GameObjectFactory.physicsGroup
Making physicsBodyType optionnal according to http://phaser.io/docs/2.6.1/Phaser.GameObjectFactory.html#physicsGroup
2016-07-12 14:13:57 +02:00
photonstorm
ac2516f5aa 2.6.1 Release. 2016-07-11 10:07:56 +01:00
photonstorm
fced3f86ec Phaser 2.6.0 Release. 2016-07-08 15:46:26 +01:00
Richard Davey
0014201917 Groups now have the following properties, which are getters and setters: centerX, centerY, left, right, top and bottom. These calculate the bounds of the Group, based on all visible children, and then allow you to apply positioning based on that. This means you can, for example, now get the horizontal center of a Group by called Group.centerX. These properties are also setters, so you can position the Groups, and it will take scale and rotation into consideration.
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.
2016-07-08 01:33:42 +01:00
Richard Davey
c0ba439e82 ArcadePhysics.Body.onCollide is a new Signal that is dispatched whenever the Body collides 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.onCollide = new Phaser.Signal() and it will be called when a collision happens, passing two arguments: the sprites which collided.
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.
2016-07-07 23:16:18 +01:00
Richard Davey
6ba3c9401f ArcadePhysics.Body.setCircle is a new method that allows you to define an Arcade Physics Body as being a circle instead of a rectangle. You can control the radius of the body and the offset from the parent sprite.
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.
2016-07-07 21:58:39 +01:00
Richard Davey
63158a1dbf Argument swapped for destroyBaseTexture. 2016-07-06 22:31:26 +01:00
Richard Davey
1b4d0330bf TypeScript updates. 2016-07-06 22:19:17 +01:00
Richard Davey
3642ff0489 Phaser.Color.toABGR converts RGBA components to a 32 bit integer in AABBGGRR format. 2016-07-04 18:50:42 +01:00