mirror of
https://github.com/wassname/phaser.git
synced 2026-07-21 12:40:56 +08:00
Adding Type support for collision checks.
This commit is contained in:
+14
-1
@@ -7,7 +7,20 @@ var Phaser = Phaser || {
|
||||
GAMES: [],
|
||||
AUTO: 0,
|
||||
CANVAS: 1,
|
||||
WEBGL: 2
|
||||
WEBGL: 2,
|
||||
|
||||
SPRITE: 0,
|
||||
BUTTON: 1,
|
||||
BULLET: 2,
|
||||
GRAPHICS: 3,
|
||||
TEXT: 4,
|
||||
TILESPRITE: 5,
|
||||
BITMAPTEXT: 6,
|
||||
GROUP: 7,
|
||||
RENDERTEXTURE: 8,
|
||||
TILEMAP: 9,
|
||||
TILEMAPLAYER: 10,
|
||||
EMITTER: 11
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ Phaser.Group = function (game, parent, name, useStage) {
|
||||
}
|
||||
}
|
||||
|
||||
this.type = Phaser.GROUP;
|
||||
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ Phaser.Button = function (game, x, y, key, callback, callbackContext, overFrame,
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, key, outFrame);
|
||||
|
||||
this.type = Phaser.BUTTON;
|
||||
|
||||
this._onOverFrameName = null;
|
||||
this._onOutFrameName = null;
|
||||
this._onDownFrameName = null;
|
||||
|
||||
@@ -14,6 +14,8 @@ Phaser.Graphics = function (game, x, y) {
|
||||
|
||||
PIXI.DisplayObjectContainer.call(this);
|
||||
|
||||
this.type = Phaser.GRAPHICS;
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ Phaser.RenderTexture = function (game, key, width, height) {
|
||||
|
||||
this.frame = new PIXI.Rectangle(0, 0, this.width, this.height);
|
||||
|
||||
this.type = Phaser.RENDERTEXTURE;
|
||||
|
||||
if (PIXI.gl)
|
||||
{
|
||||
this.initWebGL();
|
||||
|
||||
@@ -17,6 +17,8 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
||||
|
||||
this.name = '';
|
||||
|
||||
this.type = Phaser.SPRITE;
|
||||
|
||||
this.renderOrderID = -1;
|
||||
|
||||
// If you would like the Sprite to have a lifespan once 'born' you can set this to a positive value. Handy for particles, bullets, etc.
|
||||
|
||||
@@ -14,6 +14,8 @@ Phaser.Text = function (game, x, y, text, style) {
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, canvasID);
|
||||
|
||||
this.type = Phaser.TEXT;
|
||||
|
||||
this.setText(text);
|
||||
this.setStyle(style);
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ Phaser.TileSprite = function (game, x, y, width, height, key, frame) {
|
||||
|
||||
PIXI.TilingSprite.call(this, this.texture, width, height);
|
||||
|
||||
this.type = Phaser.TILESPRITE;
|
||||
|
||||
/**
|
||||
* The scaling of the image that is being tiled
|
||||
*
|
||||
|
||||
@@ -14,6 +14,8 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) {
|
||||
|
||||
this.name = 'emitter' + this.game.particles.ID++;
|
||||
|
||||
this.type = Phaser.EMITTER;
|
||||
|
||||
/**
|
||||
* The X position of the top left corner of the emitter in world space.
|
||||
*/
|
||||
|
||||
@@ -179,11 +179,35 @@ Phaser.Physics.Arcade.prototype = {
|
||||
*/
|
||||
overlap: function (object1, object2, notifyCallback, processCallback, callbackContext) {
|
||||
|
||||
object1 = object1 || null;
|
||||
object2 = object2 || null;
|
||||
notifyCallback = notifyCallback || null;
|
||||
processCallback = processCallback || this.separate;
|
||||
callbackContext = callbackContext || this;
|
||||
|
||||
// World vs. World check
|
||||
if (object1 == null)
|
||||
{
|
||||
// Scan the entire display list, comparing every object! (ouch)
|
||||
if (this.game.world._container.first._iNext)
|
||||
{
|
||||
var currentNode = this.game.world._container.first._iNext;
|
||||
|
||||
do
|
||||
{
|
||||
if (checkExists == false || (checkExists && currentNode.exists))
|
||||
{
|
||||
callback.call(callbackContext, currentNode);
|
||||
}
|
||||
|
||||
currentNode = currentNode._iNext;
|
||||
}
|
||||
while (currentNode != this.game.world._container.last._iNext);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get the ships top-most ID. If the length of that ID is 1 then we can ignore every other result,
|
||||
// it's simply not colliding with anything :)
|
||||
var potentials = this.quadTree.retrieve(object1);
|
||||
|
||||
@@ -51,6 +51,8 @@ Phaser.Tilemap = function (game, key, x, y, resizeWorld, tileWidth, tileHeight)
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
|
||||
this.type = Phaser.TILEMAP;
|
||||
|
||||
this.renderer = new Phaser.TilemapRenderer(this.game);
|
||||
|
||||
this.mapFormat = map.format;
|
||||
|
||||
@@ -73,6 +73,7 @@ Phaser.TilemapLayer = function (parent, id, key, mapFormat, name, tileWidth, til
|
||||
this.ID = id;
|
||||
this.name = name;
|
||||
this.key = key;
|
||||
this.type = Phaser.TILEMAPLAYER;
|
||||
|
||||
this.mapFormat = mapFormat;
|
||||
this.tileWidth = tileWidth;
|
||||
|
||||
Reference in New Issue
Block a user