mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Small tweaks to #2577 and TS defs.
This commit is contained in:
parent
8cde880d98
commit
2bd4f68ea0
3 changed files with 21 additions and 24 deletions
|
@ -320,15 +320,16 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
|
|||
### New Features
|
||||
|
||||
* The Loader has a new property `headers`. This is an object checked by XHR Requests, used to set the Request Header of certain file types. JSON and XML are pre-configured, but you can add to, or modify this property as required (thanks @stoneman1 #2585 #2485)
|
||||
*
|
||||
* Phaser now has support for Typings, the TypeScript Definition Manager. See the `typescript/readme.md` file for installation instructions (thanks @monagames #2576)
|
||||
*
|
||||
|
||||
### Updates
|
||||
|
||||
* TypeScript definitions fixes and updates (thanks)
|
||||
* Docs typo fixes (thanks @drhayes @)
|
||||
* TypeScript definitions fixes and updates (thanks @monagames)
|
||||
* Docs typo fixes (thanks @drhayes)
|
||||
* The TilemapParser will now add more data when importing Image object types from Tiled. The extra data available is: image width, image height, and flags to see if the image is flipped either horizontally, vertically or diagonally (thanks @gotenxds #2564 #2554)
|
||||
* TilemapLayer.renderRegion has had an assignment to the obsolete `tileColor` property removed (thanks @cryptographer #2583)
|
||||
* Group.getFurthestFrom and Group.getClosestTo has a new optional argument: `callback`. This allows you to apply your own additional filtering to the distance checks, ultimately influencing the selected child (thanks @LoneStranger #2577)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -2213,13 +2213,16 @@ Phaser.Group.prototype.getBottom = function () {
|
|||
*
|
||||
* 'close' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* If callback returns true, the object is considered for distance. If callback is null, then any child will satisfy the criteria.
|
||||
* You can use the optional `callback` argument to apply your own filter to the distance checks.
|
||||
* If the child is closer then the previous child, it will be sent to `callback` as the first argument,
|
||||
* with the distance as the second. The callback should return `true` if it passes your
|
||||
* filtering criteria, otherwise it should return `false`.
|
||||
*
|
||||
* @method Phaser.Group#getClosestTo
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @param {function} [callback=null] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second.
|
||||
* @param {function} [callback] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria.
|
||||
* @param {object} [callbackContext] - The context in which the function should be called (usually 'this').
|
||||
* @return {any} The child closest to given object, or null if no child was found.
|
||||
* @return {any} The child closest to given object, or `null` if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getClosestTo = function (object, callback, callbackContext) {
|
||||
|
||||
|
@ -2227,11 +2230,6 @@ Phaser.Group.prototype.getClosestTo = function (object, callback, callbackContex
|
|||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
if (!callback)
|
||||
{
|
||||
callback = function() {return true;};
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
@ -2240,7 +2238,7 @@ Phaser.Group.prototype.getClosestTo = function (object, callback, callbackContex
|
|||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance < distance && callback.call(callbackContext, child, tempDistance))
|
||||
if (tempDistance > distance && (!callback || callback.call(callbackContext, child, tempDistance)))
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
|
@ -2259,13 +2257,16 @@ Phaser.Group.prototype.getClosestTo = function (object, callback, callbackContex
|
|||
*
|
||||
* 'furthest away' is determined by the distance from the objects `x` and `y` properties compared to the childs `x` and `y` properties.
|
||||
*
|
||||
* If callback returns true, the object is considered for distance. If callback is null, then any child will satisfy the criteria.
|
||||
* You can use the optional `callback` argument to apply your own filter to the distance checks.
|
||||
* If the child is closer then the previous child, it will be sent to `callback` as the first argument,
|
||||
* with the distance as the second. The callback should return `true` if it passes your
|
||||
* filtering criteria, otherwise it should return `false`.
|
||||
*
|
||||
* @method Phaser.Group#getFurthestFrom
|
||||
* @param {any} object - The object used to determine the distance. This can be a Sprite, Group, Image or any object with public x and y properties.
|
||||
* @param {function} [callback=null] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second.
|
||||
* @param {function} [callback] - The function that each child will be evaluated against. Each child of the group will be passed to it as its first parameter, with the distance as the second. It should return `true` if the child passes the matching criteria.
|
||||
* @param {object} [callbackContext] - The context in which the function should be called (usually 'this').
|
||||
* @return {any} The child furthest from the given object, or null if no child was found.
|
||||
* @return {any} The child furthest from the given object, or `null` if no child was found.
|
||||
*/
|
||||
Phaser.Group.prototype.getFurthestFrom = function (object, callback, callbackContext) {
|
||||
|
||||
|
@ -2273,11 +2274,6 @@ Phaser.Group.prototype.getFurthestFrom = function (object, callback, callbackCon
|
|||
var tempDistance = 0;
|
||||
var result = null;
|
||||
|
||||
if (!callback)
|
||||
{
|
||||
callback = function() {return true;};
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.children.length; i++)
|
||||
{
|
||||
var child = this.children[i];
|
||||
|
@ -2286,7 +2282,7 @@ Phaser.Group.prototype.getFurthestFrom = function (object, callback, callbackCon
|
|||
{
|
||||
tempDistance = Math.abs(Phaser.Point.distance(object, child));
|
||||
|
||||
if (tempDistance > distance && callback.call(callbackContext, child, tempDistance))
|
||||
if (tempDistance > distance && (!callback || callback.call(callbackContext, child, tempDistance)))
|
||||
{
|
||||
distance = tempDistance;
|
||||
result = child;
|
||||
|
|
6
typescript/phaser.d.ts
vendored
6
typescript/phaser.d.ts
vendored
|
@ -1,7 +1,7 @@
|
|||
/// <reference path="pixi.d.ts" />
|
||||
/// <reference path="p2.d.ts" />
|
||||
|
||||
// Type definitions for Phaser 2.5.0 - 17th June 2016
|
||||
// Type definitions for Phaser 2.5.1 - 21st June 2016
|
||||
// Project: https://github.com/photonstorm/phaser
|
||||
|
||||
declare module "phaser" {
|
||||
|
@ -1764,11 +1764,11 @@ declare module Phaser {
|
|||
getAt(index: number): PIXI.DisplayObject | number;
|
||||
getBottom(): any;
|
||||
getByName(name: string): any;
|
||||
getClosestTo(object: any): any;
|
||||
getClosestTo(object: any, callback?: Function, callbackContext?: any): any;
|
||||
getFirstAlive(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
getFirstDead(createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
getFirstExists(exists: boolean, createIfNull?: boolean, x?: number, y?: number, key?: string | Phaser.RenderTexture | Phaser.BitmapData | Phaser.Video | PIXI.Texture, frame?: string | number): any;
|
||||
getFurthestFrom(object: any): any;
|
||||
getFurthestFrom(object: any, callback?: Function, callbackContext?: any): any;
|
||||
getIndex(child: any): number;
|
||||
getRandom(startIndex?: number, length?: number): any;
|
||||
getTop(): any;
|
||||
|
|
Loading…
Add table
Reference in a new issue