mirror of
https://github.com/photonstorm/phaser
synced 2024-09-21 15:01:57 +00:00
Tidied up the Examples, fixed Arcade Physics Body, added Body enable support to Group and fixed QuadTree.
This commit is contained in:
parent
c4183d200f
commit
8fff38618d
56 changed files with 24334 additions and 24707 deletions
5370
build/custom/ninja.js
Normal file
5370
build/custom/ninja.js
Normal file
File diff suppressed because it is too large
Load diff
3
build/custom/ninja.min.js
vendored
Normal file
3
build/custom/ninja.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3016
build/custom/p2.js
3016
build/custom/p2.js
File diff suppressed because it is too large
Load diff
8
build/custom/p2.min.js
vendored
8
build/custom/p2.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
14
build/custom/phaser-no-libs.min.js
vendored
14
build/custom/phaser-no-libs.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -9035,7 +9035,6 @@ PIXI.BaseTexture.prototype.updateSourceImage = function(newSrc)
|
|||
PIXI.BaseTexture.fromImage = function(imageUrl, crossorigin, scaleMode)
|
||||
{
|
||||
var baseTexture = PIXI.BaseTextureCache[imageUrl];
|
||||
crossorigin = !crossorigin;
|
||||
|
||||
if(!baseTexture)
|
||||
{
|
||||
|
@ -9561,7 +9560,7 @@ PIXI.RenderTexture.tempMatrix = new PIXI.Matrix();
|
|||
}
|
||||
exports.PIXI = PIXI;
|
||||
} else if (typeof define !== 'undefined' && define.amd) {
|
||||
define(PIXI);
|
||||
define('PIXI', (function() { return root.PIXI = PIXI; })() );
|
||||
} else {
|
||||
root.PIXI = PIXI;
|
||||
}
|
||||
|
|
2
build/custom/pixi.min.js
vendored
2
build/custom/pixi.min.js
vendored
File diff suppressed because one or more lines are too long
74
build/phaser.d.ts
vendored
74
build/phaser.d.ts
vendored
|
@ -1,76 +1,3 @@
|
|||
declare class SAT {
|
||||
|
||||
flattenPointsOn(points: Array<SAT.Vector>, normal: SAT.Vector, result: Array<number>): Array<number>;
|
||||
isSeparatingAxis(aPos: SAT.Vector, bPos: SAT.Vector, aPoints: Array<SAT.Vector>, bPoints: Array<SAT.Vector>, axis: SAT.Vector, response: SAT.Response): boolean;
|
||||
vornoiRegion(line: SAT.Vector, point: SAT.Vector): number;
|
||||
testCircleCircle(a: SAT.Circle, b: SAT.Circle, response: SAT.Response): boolean;
|
||||
testPolygonCircle(a: SAT.Polygon, b: SAT.Circle, response: SAT.Response): boolean;
|
||||
testCirclePolygon(a: SAT.Circle, b: SAT.Polygon, response: SAT.Response): boolean;
|
||||
testPolygonPolygon(a: SAT.Polygon, b: SAT.Polygon, response: SAT.Response): boolean;
|
||||
|
||||
}
|
||||
|
||||
declare module SAT {
|
||||
|
||||
class Vector {
|
||||
constructor(x: number, y: number);
|
||||
x: number;
|
||||
y: number;
|
||||
copy(other: SAT.Vector): SAT.Vector;
|
||||
perp(): SAT.Vector;
|
||||
rotate(angle: number): SAT.Vector;
|
||||
rotatePrecalc(sin: number, cos: number): SAT.Vector;
|
||||
reverse(): SAT.Vector;
|
||||
normalize(): SAT.Vector;
|
||||
add(other: SAT.Vector): SAT.Vector;
|
||||
sub(other: SAT.Vector): SAT.Vector;
|
||||
scale(x: number, y: number): SAT.Vector;
|
||||
project(other: SAT.Vector): SAT.Vector;
|
||||
projectN(other: SAT.Vector): SAT.Vector;
|
||||
reflect(axis: SAT.Vector): SAT.Vector;
|
||||
reflectN(axis: SAT.Vector): SAT.Vector;
|
||||
dot(other: SAT.Vector): SAT.Vector;
|
||||
len2(): SAT.Vector;
|
||||
len(): SAT.Vector;
|
||||
}
|
||||
|
||||
class Circle {
|
||||
constructor(pos: SAT.Vector, radius: number);
|
||||
pos: SAT.Vector;
|
||||
r: number;
|
||||
}
|
||||
|
||||
class Polygon {
|
||||
constructor(pos: SAT.Vector, points: Array<SAT.Vector>);
|
||||
pos: SAT.Vector;
|
||||
points: Array<SAT.Vector>;
|
||||
recalc(): SAT.Polygon;
|
||||
rotate(angle: number): SAT.Polygon;
|
||||
scale(x: number, y: number): SAT.Polygon;
|
||||
translate(x: number, y: number): SAT.Polygon;
|
||||
}
|
||||
|
||||
class Box {
|
||||
constructor(pos: SAT.Vector, w: number, h: number);
|
||||
pos: SAT.Vector;
|
||||
w: number;
|
||||
h: number;
|
||||
toPolygon(): SAT.Polygon;
|
||||
}
|
||||
|
||||
class Response {
|
||||
constructor();
|
||||
a: any;
|
||||
b: any;
|
||||
overlapN: SAT.Vector;
|
||||
overlapV: SAT.Vector;
|
||||
clear(): SAT.Response;
|
||||
aInB: boolean;
|
||||
bInA: boolean;
|
||||
overlap: number;
|
||||
}
|
||||
}
|
||||
|
||||
// Type definitions for PIXI 1.5.1
|
||||
// Project: https://github.com/GoodBoyDigital/pixi.js/
|
||||
// Original 1.3 by: xperiments <http://github.com/xperiments>
|
||||
|
@ -2890,6 +2817,7 @@ declare module Phaser {
|
|||
insert(body: any): void;
|
||||
populate(group: Phaser.Group): void;
|
||||
populateHandler(sprite: Phaser.Sprite): void;
|
||||
reset(x: number, y: number, width: number, height: number, maxObject?: number, maxLevels?: number, level?: number): void;
|
||||
retrieve(sprite: Object): any[];
|
||||
split(): void;
|
||||
//I am not sure these are relevant? Searching in the code yeilds no result
|
||||
|
|
30541
build/phaser.js
30541
build/phaser.js
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
26
build/phaser.min.js
vendored
26
build/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -33,6 +33,144 @@
|
|||
"title": "starling atlas"
|
||||
}
|
||||
],
|
||||
"arcade physics": [
|
||||
{
|
||||
"file": "accelerate+to+pointer.js",
|
||||
"title": "accelerate to pointer"
|
||||
},
|
||||
{
|
||||
"file": "angle+between.js",
|
||||
"title": "angle between"
|
||||
},
|
||||
{
|
||||
"file": "angle+to+pointer.js",
|
||||
"title": "angle to pointer"
|
||||
},
|
||||
{
|
||||
"file": "angular+acceleration.js",
|
||||
"title": "angular acceleration"
|
||||
},
|
||||
{
|
||||
"file": "angular+velocity.js",
|
||||
"title": "angular velocity"
|
||||
},
|
||||
{
|
||||
"file": "body+scale.js",
|
||||
"title": "body scale"
|
||||
},
|
||||
{
|
||||
"file": "bounce+accelerator.js",
|
||||
"title": "bounce accelerator"
|
||||
},
|
||||
{
|
||||
"file": "bounce+knock.js",
|
||||
"title": "bounce knock"
|
||||
},
|
||||
{
|
||||
"file": "bounce+with+gravity.js",
|
||||
"title": "bounce with gravity"
|
||||
},
|
||||
{
|
||||
"file": "bounce.js",
|
||||
"title": "bounce"
|
||||
},
|
||||
{
|
||||
"file": "bounding+box.js",
|
||||
"title": "bounding box"
|
||||
},
|
||||
{
|
||||
"file": "gravity.js",
|
||||
"title": "gravity"
|
||||
},
|
||||
{
|
||||
"file": "group+vs+group.js",
|
||||
"title": "group vs group"
|
||||
},
|
||||
{
|
||||
"file": "group+vs+self.js",
|
||||
"title": "group vs self"
|
||||
},
|
||||
{
|
||||
"file": "larger+bounding+box.js",
|
||||
"title": "larger bounding box"
|
||||
},
|
||||
{
|
||||
"file": "launcher+follow+world.js",
|
||||
"title": "launcher follow world"
|
||||
},
|
||||
{
|
||||
"file": "launcher+follow.js",
|
||||
"title": "launcher follow"
|
||||
},
|
||||
{
|
||||
"file": "launcher.js",
|
||||
"title": "launcher"
|
||||
},
|
||||
{
|
||||
"file": "mass+velocity+test.js",
|
||||
"title": "mass velocity test"
|
||||
},
|
||||
{
|
||||
"file": "move+towards+object.js",
|
||||
"title": "move towards object"
|
||||
},
|
||||
{
|
||||
"file": "multi+angle+to+pointer.js",
|
||||
"title": "multi angle to pointer"
|
||||
},
|
||||
{
|
||||
"file": "offset+bounding+box.js",
|
||||
"title": "offset bounding box"
|
||||
},
|
||||
{
|
||||
"file": "one+way+collision.js",
|
||||
"title": "one way collision"
|
||||
},
|
||||
{
|
||||
"file": "process+callback.js",
|
||||
"title": "process callback"
|
||||
},
|
||||
{
|
||||
"file": "quadtree+-+collision+infos.js",
|
||||
"title": "quadtree - collision infos"
|
||||
},
|
||||
{
|
||||
"file": "quadtree+-+ids.js",
|
||||
"title": "quadtree - ids"
|
||||
},
|
||||
{
|
||||
"file": "rotated+bounding+box.js",
|
||||
"title": "rotated bounding box"
|
||||
},
|
||||
{
|
||||
"file": "ship+trail.js",
|
||||
"title": "ship trail"
|
||||
},
|
||||
{
|
||||
"file": "shoot+the+pointer.js",
|
||||
"title": "shoot the pointer"
|
||||
},
|
||||
{
|
||||
"file": "snake.js",
|
||||
"title": "snake"
|
||||
},
|
||||
{
|
||||
"file": "sprite+bounds.js",
|
||||
"title": "sprite bounds"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+group.js",
|
||||
"title": "sprite vs group"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+sprite.js",
|
||||
"title": "sprite vs sprite"
|
||||
},
|
||||
{
|
||||
"file": "vertical+collision.js",
|
||||
"title": "vertical collision"
|
||||
}
|
||||
],
|
||||
"audio": [
|
||||
{
|
||||
"file": "loop.js",
|
||||
|
@ -117,68 +255,6 @@
|
|||
"title": "world sprite"
|
||||
}
|
||||
],
|
||||
"collision": [
|
||||
{
|
||||
"file": "body+scale.js",
|
||||
"title": "body scale"
|
||||
},
|
||||
{
|
||||
"file": "bounding+box.js",
|
||||
"title": "bounding box"
|
||||
},
|
||||
{
|
||||
"file": "circle+body.js",
|
||||
"title": "circle body"
|
||||
},
|
||||
{
|
||||
"file": "circle+vs+polygon.js",
|
||||
"title": "circle vs polygon"
|
||||
},
|
||||
{
|
||||
"file": "group+vs+group.js",
|
||||
"title": "group vs group"
|
||||
},
|
||||
{
|
||||
"file": "group+vs+self.js",
|
||||
"title": "group vs self"
|
||||
},
|
||||
{
|
||||
"file": "larger+bounding+box.js",
|
||||
"title": "larger bounding box"
|
||||
},
|
||||
{
|
||||
"file": "offset+bounding+box.js",
|
||||
"title": "offset bounding box"
|
||||
},
|
||||
{
|
||||
"file": "one+way+collision.js",
|
||||
"title": "one way collision"
|
||||
},
|
||||
{
|
||||
"file": "polygon+body.js",
|
||||
"title": "polygon body"
|
||||
},
|
||||
{
|
||||
"file": "process+callback.js",
|
||||
"title": "process callback"
|
||||
},
|
||||
{
|
||||
"file": "rotated+bounding+box.js",
|
||||
"title": "rotated bounding box"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+group.js",
|
||||
"title": "sprite vs group"
|
||||
},
|
||||
{
|
||||
"file": "sprite+vs+sprite.js",
|
||||
"title": "sprite vs sprite"
|
||||
},
|
||||
{
|
||||
"file": "vertical+collision.js",
|
||||
"title": "vertical collision"
|
||||
}
|
||||
],
|
||||
"debug": [
|
||||
{
|
||||
"file": "debug+camera.js",
|
||||
|
@ -619,100 +695,6 @@
|
|||
"title": "zero gravity"
|
||||
}
|
||||
],
|
||||
"physics": [
|
||||
{
|
||||
"file": "accelerate+to+pointer.js",
|
||||
"title": "accelerate to pointer"
|
||||
},
|
||||
{
|
||||
"file": "angle+between.js",
|
||||
"title": "angle between"
|
||||
},
|
||||
{
|
||||
"file": "angle+to+pointer.js",
|
||||
"title": "angle to pointer"
|
||||
},
|
||||
{
|
||||
"file": "angular+acceleration.js",
|
||||
"title": "angular acceleration"
|
||||
},
|
||||
{
|
||||
"file": "angular+velocity.js",
|
||||
"title": "angular velocity"
|
||||
},
|
||||
{
|
||||
"file": "bounce+accelerator.js",
|
||||
"title": "bounce accelerator"
|
||||
},
|
||||
{
|
||||
"file": "bounce+knock.js",
|
||||
"title": "bounce knock"
|
||||
},
|
||||
{
|
||||
"file": "bounce+with+gravity.js",
|
||||
"title": "bounce with gravity"
|
||||
},
|
||||
{
|
||||
"file": "bounce.js",
|
||||
"title": "bounce"
|
||||
},
|
||||
{
|
||||
"file": "framerate+independence.js",
|
||||
"title": "framerate independence"
|
||||
},
|
||||
{
|
||||
"file": "gravity.js",
|
||||
"title": "gravity"
|
||||
},
|
||||
{
|
||||
"file": "launcher+follow+world.js",
|
||||
"title": "launcher follow world"
|
||||
},
|
||||
{
|
||||
"file": "launcher+follow.js",
|
||||
"title": "launcher follow"
|
||||
},
|
||||
{
|
||||
"file": "launcher.js",
|
||||
"title": "launcher"
|
||||
},
|
||||
{
|
||||
"file": "mass+velocity+test.js",
|
||||
"title": "mass velocity test"
|
||||
},
|
||||
{
|
||||
"file": "move+towards+object.js",
|
||||
"title": "move towards object"
|
||||
},
|
||||
{
|
||||
"file": "multi+angle+to+pointer.js",
|
||||
"title": "multi angle to pointer"
|
||||
},
|
||||
{
|
||||
"file": "quadtree+-+collision+infos.js",
|
||||
"title": "quadtree - collision infos"
|
||||
},
|
||||
{
|
||||
"file": "quadtree+-+ids.js",
|
||||
"title": "quadtree - ids"
|
||||
},
|
||||
{
|
||||
"file": "ship+trail.js",
|
||||
"title": "ship trail"
|
||||
},
|
||||
{
|
||||
"file": "shoot+the+pointer.js",
|
||||
"title": "shoot the pointer"
|
||||
},
|
||||
{
|
||||
"file": "snake.js",
|
||||
"title": "snake"
|
||||
},
|
||||
{
|
||||
"file": "sprite+bounds.js",
|
||||
"title": "sprite bounds"
|
||||
}
|
||||
],
|
||||
"sprites": [
|
||||
{
|
||||
"file": "add+a+sprite.js",
|
||||
|
|
|
@ -7,172 +7,7 @@
|
|||
<script src="_site/js/jquery-2.0.3.min.js" type="text/javascript"></script>
|
||||
<script src="_site/js/purl.js" type="text/javascript"></script>
|
||||
<script src="_site/js/gamecontroller.js" type="text/javascript"></script>
|
||||
<!--
|
||||
If you're wondering why we embed each script separately, and not just the single-file phaser lib
|
||||
it's because it makes debugging *significantly* easier for us. Feel free to replace all the below
|
||||
with just a call to ../build/phaser.js instead if you prefer.
|
||||
-->
|
||||
<script src="../src/p2.js"></script>
|
||||
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
<script src="../src/pixi/core/Point.js"></script>
|
||||
<script src="../src/pixi/core/Rectangle.js"></script>
|
||||
<script src="../src/pixi/core/Polygon.js"></script>
|
||||
<script src="../src/pixi/core/Circle.js"></script>
|
||||
<script src="../src/pixi/core/Ellipse.js"></script>
|
||||
<script src="../src/pixi/core/Matrix.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
<script src="../src/pixi/display/SpriteBatch.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/text/Text.js"></script>
|
||||
<script src="../src/pixi/text/BitmapText.js"></script>
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/utils/Utils.js"></script>
|
||||
<script src="../src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="../src/pixi/utils/Polyk.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLShaderUtils.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PixiShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PixiFastShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/StripShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PrimitiveShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLMaskManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLShaderManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLFilterManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/FilterTexture.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/utils/CanvasMaskManager.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/utils/CanvasTinter.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="../src/pixi/primitives/Graphics.js"></script>
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="../src/pixi/textures/Texture.js"></script>
|
||||
<script src="../src/pixi/textures/RenderTexture.js"></script>
|
||||
|
||||
<script src="../src/Phaser.js"></script>
|
||||
<script src="../src/utils/Utils.js"></script>
|
||||
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Rectangle.js"></script>
|
||||
<script src="../src/geom/Line.js"></script>
|
||||
<script src="../src/geom/Ellipse.js"></script>
|
||||
<script src="../src/geom/Polygon.js"></script>
|
||||
|
||||
<script src="../src/core/Camera.js"></script>
|
||||
<script src="../src/core/State.js"></script>
|
||||
<script src="../src/core/StateManager.js"></script>
|
||||
<script src="../src/core/LinkedList.js"></script>
|
||||
<script src="../src/core/Signal.js"></script>
|
||||
<script src="../src/core/SignalBinding.js"></script>
|
||||
<script src="../src/core/Filter.js"></script>
|
||||
<script src="../src/core/Plugin.js"></script>
|
||||
<script src="../src/core/PluginManager.js"></script>
|
||||
<script src="../src/core/Stage.js"></script>
|
||||
<script src="../src/core/Group.js"></script>
|
||||
<script src="../src/core/World.js"></script>
|
||||
<script src="../src/core/Game.js"></script>
|
||||
<script src="../src/core/ScaleManager.js"></script>
|
||||
|
||||
<script src="../src/input/Input.js"></script>
|
||||
<script src="../src/input/Key.js"></script>
|
||||
<script src="../src/input/Keyboard.js"></script>
|
||||
<script src="../src/input/Mouse.js"></script>
|
||||
<script src="../src/input/MSPointer.js"></script>
|
||||
<script src="../src/input/Pointer.js"></script>
|
||||
<script src="../src/input/Touch.js"></script>
|
||||
<script src="../src/input/Gamepad.js"></script>
|
||||
<script src="../src/input/SinglePad.js"></script>
|
||||
<script src="../src/input/GamepadButton.js"></script>
|
||||
<script src="../src/input/InputHandler.js"></script>
|
||||
<script src="../src/input/Gestures.js"></script>
|
||||
|
||||
<script src="../src/gameobjects/Events.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectCreator.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="../src/gameobjects/BitmapData.js"></script>
|
||||
<script src="../src/gameobjects/Sprite.js"></script>
|
||||
<script src="../src/gameobjects/Image.js"></script>
|
||||
<script src="../src/gameobjects/TileSprite.js"></script>
|
||||
<script src="../src/gameobjects/Text.js"></script>
|
||||
<script src="../src/gameobjects/BitmapText.js"></script>
|
||||
<script src="../src/gameobjects/Button.js"></script>
|
||||
<script src="../src/gameobjects/Graphics.js"></script>
|
||||
<script src="../src/gameobjects/RenderTexture.js"></script>
|
||||
<script src="../src/gameobjects/SpriteBatch.js"></script>
|
||||
<script src="../src/gameobjects/RetroFont.js"></script>
|
||||
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/QuadTree.js"></script>
|
||||
|
||||
<script src="../src/net/Net.js"></script>
|
||||
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
|
||||
<script src="../src/time/Time.js"></script>
|
||||
<script src="../src/time/Timer.js"></script>
|
||||
<script src="../src/time/TimerEvent.js"></script>
|
||||
|
||||
<script src="../src/animation/AnimationManager.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/AnimationParser.js"></script>
|
||||
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/loader/LoaderParser.js"></script>
|
||||
|
||||
<script src="../src/sound/Sound.js"></script>
|
||||
<script src="../src/sound/SoundManager.js"></script>
|
||||
|
||||
<script src="../src/utils/Debug.js"></script>
|
||||
<script src="../src/utils/Color.js"></script>
|
||||
|
||||
<script src="../src/physics/Physics.js"></script>
|
||||
|
||||
<script src="../src/physics/arcade/World.js"></script>
|
||||
<script src="../src/physics/arcade/Body.js"></script>
|
||||
<script src="../src/physics/arcade/QuadTree.js"></script>
|
||||
|
||||
<script src="../src/physics/ninja/World.js"></script>
|
||||
<script src="../src/physics/ninja/Body.js"></script>
|
||||
<script src="../src/physics/ninja/AABB.js"></script>
|
||||
<script src="../src/physics/ninja/Tile.js"></script>
|
||||
<script src="../src/physics/ninja/Circle.js"></script>
|
||||
|
||||
<script src="../src/physics/p2/World.js"></script>
|
||||
<script src="../src/physics/p2/PointProxy.js"></script>
|
||||
<script src="../src/physics/p2/InversePointProxy.js"></script>
|
||||
<script src="../src/physics/p2/Body.js"></script>
|
||||
<script src="../src/physics/p2/Spring.js"></script>
|
||||
<script src="../src/physics/p2/Material.js"></script>
|
||||
<script src="../src/physics/p2/ContactMaterial.js"></script>
|
||||
<script src="../src/physics/p2/CollisionGroup.js"></script>
|
||||
|
||||
<script src="../src/particles/Particles.js"></script>
|
||||
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
|
||||
<script src="../src/particles/arcade/Emitter.js"></script>
|
||||
|
||||
<script src="../src/tilemap/Tile.js"></script>
|
||||
<script src="../src/tilemap/Tilemap.js"></script>
|
||||
<script src="../src/tilemap/TilemapLayer.js"></script>
|
||||
<script src="../src/tilemap/TilemapParser.js"></script>
|
||||
<script src="../src/tilemap/Tileset.js"></script>
|
||||
|
||||
<script src="../build/phaser.js"></script>
|
||||
<script src="_site/js/phaser-viewer.js" type="text/javascript"></script>
|
||||
<script src="_site/js/run_prettify.js"></script>
|
||||
<link href="_site/css/phaser-examples.css" media="screen" rel="stylesheet" type="text/css">
|
||||
|
|
|
@ -6,172 +6,7 @@
|
|||
<base href="../"></base>
|
||||
<script src="_site/js/jquery-2.0.3.min.js" type="text/javascript"></script>
|
||||
<script src="_site/js/purl.js" type="text/javascript"></script>
|
||||
<script src="_site/js/gamecontroller.js" type="text/javascript"></script>
|
||||
<!--
|
||||
If you're wondering why we embed each script separately, and not just the single-file phaser lib
|
||||
it's because it makes debugging *significantly* easier for us. Feel free to replace all the below
|
||||
with just a call to ../build/phaser.js instead if you prefer.
|
||||
-->
|
||||
<script src="../src/p2.js"></script>
|
||||
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
<script src="../src/pixi/core/Point.js"></script>
|
||||
<script src="../src/pixi/core/Rectangle.js"></script>
|
||||
<script src="../src/pixi/core/Polygon.js"></script>
|
||||
<script src="../src/pixi/core/Circle.js"></script>
|
||||
<script src="../src/pixi/core/Ellipse.js"></script>
|
||||
<script src="../src/pixi/core/Matrix.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
<script src="../src/pixi/display/SpriteBatch.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/text/Text.js"></script>
|
||||
<script src="../src/pixi/text/BitmapText.js"></script>
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/utils/Utils.js"></script>
|
||||
<script src="../src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="../src/pixi/utils/Polyk.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLShaderUtils.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PixiShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PixiFastShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/StripShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/shaders/PrimitiveShader.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLMaskManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLShaderManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLFastSpriteBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/WebGLFilterManager.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/utils/FilterTexture.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/utils/CanvasMaskManager.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/utils/CanvasTinter.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="../src/pixi/primitives/Graphics.js"></script>
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="../src/pixi/textures/Texture.js"></script>
|
||||
<script src="../src/pixi/textures/RenderTexture.js"></script>
|
||||
|
||||
<script src="../src/Phaser.js"></script>
|
||||
<script src="../src/utils/Utils.js"></script>
|
||||
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Rectangle.js"></script>
|
||||
<script src="../src/geom/Line.js"></script>
|
||||
<script src="../src/geom/Ellipse.js"></script>
|
||||
<script src="../src/geom/Polygon.js"></script>
|
||||
|
||||
<script src="../src/core/Camera.js"></script>
|
||||
<script src="../src/core/State.js"></script>
|
||||
<script src="../src/core/StateManager.js"></script>
|
||||
<script src="../src/core/LinkedList.js"></script>
|
||||
<script src="../src/core/Signal.js"></script>
|
||||
<script src="../src/core/SignalBinding.js"></script>
|
||||
<script src="../src/core/Filter.js"></script>
|
||||
<script src="../src/core/Plugin.js"></script>
|
||||
<script src="../src/core/PluginManager.js"></script>
|
||||
<script src="../src/core/Stage.js"></script>
|
||||
<script src="../src/core/Group.js"></script>
|
||||
<script src="../src/core/World.js"></script>
|
||||
<script src="../src/core/Game.js"></script>
|
||||
<script src="../src/core/ScaleManager.js"></script>
|
||||
|
||||
<script src="../src/input/Input.js"></script>
|
||||
<script src="../src/input/Key.js"></script>
|
||||
<script src="../src/input/Keyboard.js"></script>
|
||||
<script src="../src/input/Mouse.js"></script>
|
||||
<script src="../src/input/MSPointer.js"></script>
|
||||
<script src="../src/input/Pointer.js"></script>
|
||||
<script src="../src/input/Touch.js"></script>
|
||||
<script src="../src/input/Gamepad.js"></script>
|
||||
<script src="../src/input/SinglePad.js"></script>
|
||||
<script src="../src/input/GamepadButton.js"></script>
|
||||
<script src="../src/input/InputHandler.js"></script>
|
||||
<script src="../src/input/Gestures.js"></script>
|
||||
|
||||
<script src="../src/gameobjects/Events.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectCreator.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="../src/gameobjects/BitmapData.js"></script>
|
||||
<script src="../src/gameobjects/Sprite.js"></script>
|
||||
<script src="../src/gameobjects/Image.js"></script>
|
||||
<script src="../src/gameobjects/TileSprite.js"></script>
|
||||
<script src="../src/gameobjects/Text.js"></script>
|
||||
<script src="../src/gameobjects/BitmapText.js"></script>
|
||||
<script src="../src/gameobjects/Button.js"></script>
|
||||
<script src="../src/gameobjects/Graphics.js"></script>
|
||||
<script src="../src/gameobjects/RenderTexture.js"></script>
|
||||
<script src="../src/gameobjects/SpriteBatch.js"></script>
|
||||
<script src="../src/gameobjects/RetroFont.js"></script>
|
||||
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/QuadTree.js"></script>
|
||||
|
||||
<script src="../src/net/Net.js"></script>
|
||||
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
|
||||
<script src="../src/time/Time.js"></script>
|
||||
<script src="../src/time/Timer.js"></script>
|
||||
<script src="../src/time/TimerEvent.js"></script>
|
||||
|
||||
<script src="../src/animation/AnimationManager.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/AnimationParser.js"></script>
|
||||
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/loader/LoaderParser.js"></script>
|
||||
|
||||
<script src="../src/sound/Sound.js"></script>
|
||||
<script src="../src/sound/SoundManager.js"></script>
|
||||
|
||||
<script src="../src/utils/Debug.js"></script>
|
||||
<script src="../src/utils/Color.js"></script>
|
||||
|
||||
<script src="../src/physics/Physics.js"></script>
|
||||
|
||||
<script src="../src/physics/arcade/World.js"></script>
|
||||
<script src="../src/physics/arcade/Body.js"></script>
|
||||
|
||||
<script src="../src/physics/ninja/World.js"></script>
|
||||
<script src="../src/physics/ninja/Body.js"></script>
|
||||
<script src="../src/physics/ninja/AABB.js"></script>
|
||||
<script src="../src/physics/ninja/Tile.js"></script>
|
||||
<script src="../src/physics/ninja/Circle.js"></script>
|
||||
|
||||
<script src="../src/physics/p2/World.js"></script>
|
||||
<script src="../src/physics/p2/PointProxy.js"></script>
|
||||
<script src="../src/physics/p2/InversePointProxy.js"></script>
|
||||
<script src="../src/physics/p2/Body.js"></script>
|
||||
<script src="../src/physics/p2/Spring.js"></script>
|
||||
<script src="../src/physics/p2/Material.js"></script>
|
||||
<script src="../src/physics/p2/ContactMaterial.js"></script>
|
||||
<script src="../src/physics/p2/CollisionGroup.js"></script>
|
||||
|
||||
<script src="../src/particles/Particles.js"></script>
|
||||
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
|
||||
<script src="../src/particles/arcade/Emitter.js"></script>
|
||||
|
||||
<script src="../src/tilemap/Tile.js"></script>
|
||||
<script src="../src/tilemap/Tilemap.js"></script>
|
||||
<script src="../src/tilemap/TilemapLayer.js"></script>
|
||||
<script src="../src/tilemap/TilemapParser.js"></script>
|
||||
<script src="../src/tilemap/Tileset.js"></script>
|
||||
|
||||
<script src="../build/phaser.js"></script>
|
||||
<script src="_site/js/phaser-viewer.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -21,8 +21,14 @@ function create() {
|
|||
sprite = game.add.sprite(32, 200, 'phaser');
|
||||
sprite.name = 'phaser-dude';
|
||||
|
||||
// Enables the arcade physics body on the sprite
|
||||
game.physics.arcade.enable(sprite);
|
||||
|
||||
group = game.add.group();
|
||||
|
||||
// Enables the arcade physics body on all sprites this group creates
|
||||
group.enableBody = true;
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
var c = group.create(game.rnd.integerInRange(100, 770), game.rnd.integerInRange(0, 570), 'veggies', game.rnd.integerInRange(0, 36));
|
||||
|
@ -44,8 +50,7 @@ function create() {
|
|||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite, group, collisionHandler, null, this);
|
||||
game.physics.collide(group, group);
|
||||
game.physics.arcade.collide(sprite, group, collisionHandler, null, this);
|
||||
|
||||
sprite.body.velocity.x = 0;
|
||||
sprite.body.velocity.y = 0;
|
|
@ -1,51 +0,0 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('wizball', 'assets/sprites/wizball.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
sprite1 = game.add.sprite(130, 250, 'wizball');
|
||||
|
||||
// Here we've replaced the sprites body with a circle instead of a rectangle
|
||||
// The value is the radius of the body in pixels
|
||||
|
||||
sprite1.body.setCircle(46);
|
||||
sprite1.body.immovable = true;
|
||||
|
||||
sprite2 = game.add.sprite(700, 210, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
sprite2.body.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.bodyInfo(sprite2, 32, 32);
|
||||
|
||||
game.debug.physicsBody(sprite1.body);
|
||||
game.debug.physicsBody(sprite2.body);
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('parsec', 'assets/sprites/parsec.png');
|
||||
game.load.image('wizball', 'assets/sprites/wizball.png');
|
||||
game.load.image('spaceman', 'assets/sprites/exocet_spaceman.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
var sprite3;
|
||||
var sprite4;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
game.physics.gravity.y = 100;
|
||||
|
||||
sprite1 = game.add.sprite(80, 200);
|
||||
sprite1.body.setPolygon(0,0, 60,0, 100,40, 60,80, 0,80);
|
||||
sprite1.body.translate(0, 144);
|
||||
sprite1.body.immovable = true;
|
||||
sprite1.body.allowGravity = false;
|
||||
|
||||
sprite2 = game.add.sprite(450, 300, 'parsec');
|
||||
sprite2.body.setPolygon(56, -1 , 10, -5 , 1, -13 , 0, -34 , 55, -60 , 122, -78 , 165, -80 , 214, -74 , 285, -71 , 296, -44 , 298, -12 , 292, -5 , 168, -3);
|
||||
sprite2.body.translate(0, 80);
|
||||
sprite2.body.immovable = true;
|
||||
sprite2.body.allowGravity = false;
|
||||
|
||||
sprite3 = game.add.sprite(230, 400, 'spaceman');
|
||||
sprite3.body.setPolygon(34, -172 , 75, -172 , 87, -145 , 121, -52 , 105, -16 , 55, -3 , 9, -19 , 1, -57 , 24, -145);
|
||||
sprite3.body.translate(0, 175);
|
||||
sprite3.body.immovable = true;
|
||||
sprite3.body.allowGravity = false;
|
||||
|
||||
sprite4 = game.add.sprite(380, 100, 'wizball');
|
||||
sprite4.body.setCircle(46);
|
||||
sprite4.body.collideWorldBounds = true;
|
||||
sprite4.body.bounce.setTo(0.9, 0.9);
|
||||
sprite4.body.velocity.setTo(100, 100);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite4, [ sprite1, sprite2, sprite3 ]);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.bodyInfo(sprite4, 32, 32);
|
||||
|
||||
game.debug.physicsBody(sprite1.body);
|
||||
game.debug.physicsBody(sprite2.body);
|
||||
game.debug.physicsBody(sprite3.body);
|
||||
game.debug.physicsBody(sprite4.body);
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('parsec', 'assets/sprites/parsec.png');
|
||||
game.load.image('spaceman', 'assets/sprites/exocet_spaceman.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// Here we've replaced the sprites body with a polygon.
|
||||
// The point data was generated by tracing the PNGs in Physics Editor: http://www.codeandweb.com/physicseditor
|
||||
|
||||
sprite1 = game.add.sprite(550, 250, 'parsec');
|
||||
sprite1.body.setPolygon(56, -1 , 10, -5 , 1, -13 , 0, -34 , 55, -60 , 122, -78 , 165, -80 , 214, -74 , 285, -71 , 296, -44 , 298, -12 , 292, -5 , 168, -3);
|
||||
sprite1.body.translate(0, 80);
|
||||
sprite1.body.velocity.x = -100;
|
||||
|
||||
sprite2 = game.add.sprite(0, 200, 'spaceman');
|
||||
sprite2.body.setPolygon(34, -172 , 75, -172 , 87, -145 , 121, -52 , 105, -16 , 55, -3 , 9, -19 , 1, -57 , 24, -145);
|
||||
sprite2.body.translate(0, 175);
|
||||
sprite2.body.velocity.x = 100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.physicsBody(sprite1.body);
|
||||
game.debug.physicsBody(sprite2.body);
|
||||
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
// This example pokes around with the internal Phaser time and physics systems
|
||||
// just to demonstrate collision and physics behaviour with different framerates.
|
||||
// Doing this in your game is not recommended
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('sprite', 'assets/sprites/diamond.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite, box;
|
||||
|
||||
var configurations = [
|
||||
{
|
||||
framerate: null,
|
||||
description: 'Default (as fast as possible)',
|
||||
color: 0x999999
|
||||
},
|
||||
{
|
||||
framerate: 120,
|
||||
color: 0x0000FF
|
||||
},
|
||||
{
|
||||
framerate: 60,
|
||||
color: 0x00FF00
|
||||
},
|
||||
{
|
||||
framerate: 30,
|
||||
color: 0x00CCCC
|
||||
},
|
||||
{
|
||||
framerate: 11,
|
||||
color: 0xFF0000
|
||||
},
|
||||
{
|
||||
framerate: 7,
|
||||
color: 0xCC00CC
|
||||
},
|
||||
{
|
||||
framerate: 5,
|
||||
color: 0xCCCC00
|
||||
},
|
||||
{
|
||||
framerate: function() { return Math.random() * 30 + 30; },
|
||||
description: 'Jittered 30-60hz',
|
||||
color: 0x333399
|
||||
},
|
||||
{
|
||||
framerate: function() { return Math.random() * 119 + 1; },
|
||||
description: 'Jittered 1-120hz',
|
||||
color: 0x339933
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
var configurationIndex = 0;
|
||||
var currentConfiguration = configurations[0];
|
||||
|
||||
var floor = game.height - 40;
|
||||
|
||||
// Here we keep a copy of the original framerate update method
|
||||
Phaser.Time.prototype.originalUpdate = Phaser.Time.prototype.update;
|
||||
|
||||
// And replace it with one that overrides the framerate
|
||||
Phaser.Time.prototype.update = function (time) {
|
||||
|
||||
this.originalUpdate(time);
|
||||
|
||||
if(currentConfiguration.framerate)
|
||||
{
|
||||
if(typeof(currentConfiguration.framerate) == 'function')
|
||||
{
|
||||
this.physicsElapsed = 1.0 / currentConfiguration.framerate();
|
||||
} else {
|
||||
this.physicsElapsed = 1.0 / currentConfiguration.framerate;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function resetSprite()
|
||||
{
|
||||
sprite.body.x = 40;
|
||||
sprite.body.y = floor;
|
||||
sprite.body.velocity.x = 300;
|
||||
sprite.body.velocity.y = -900;
|
||||
sprite.body.gravity.y = 20;
|
||||
|
||||
};
|
||||
|
||||
function create() {
|
||||
|
||||
sprite = game.add.sprite(40, floor, 'sprite');
|
||||
sprite.body.bounce.y = 0.5;
|
||||
resetSprite();
|
||||
|
||||
for(var i = 0; i < configurations.length; i++)
|
||||
{
|
||||
configurations[i].graphics = game.add.graphics(0, 0);
|
||||
configurations[i].points = [];
|
||||
}
|
||||
|
||||
box = game.add.sprite(450, floor - 40, 'missing');
|
||||
box.width = 100;
|
||||
box.body.immovable = true;
|
||||
};
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite, box);
|
||||
|
||||
currentConfiguration.points.push([sprite.center.x, sprite.center.y]);
|
||||
|
||||
if(sprite.body.velocity.y > 0 && sprite.body.y > floor)
|
||||
{
|
||||
currentConfiguration.graphics.clear();
|
||||
currentConfiguration.graphics.lineStyle(1, currentConfiguration.color, 1)
|
||||
currentConfiguration.graphics.moveTo(currentConfiguration.points[0][0], currentConfiguration.points[0][1]);
|
||||
|
||||
for(var i = 1; i < currentConfiguration.points.length; i++)
|
||||
{
|
||||
currentConfiguration.graphics.lineTo(currentConfiguration.points[i][0], currentConfiguration.points[i][1]);
|
||||
}
|
||||
|
||||
currentConfiguration.points.length = 0;
|
||||
|
||||
configurationIndex = (configurationIndex + 1) % configurations.length;
|
||||
currentConfiguration = configurations[configurationIndex];
|
||||
|
||||
resetSprite();
|
||||
}
|
||||
};
|
||||
|
||||
function render() {
|
||||
game.debug.text("Framerate: " + (currentConfiguration.description || (currentConfiguration.framerate + 'hz')), 10, 40);
|
||||
};
|
|
@ -85,17 +85,21 @@ Phaser.Group = function (game, parent, name, addToStage) {
|
|||
*/
|
||||
this.cursor = null;
|
||||
|
||||
/**
|
||||
* @property {number} _cursorIndex - Internal pointer.
|
||||
* @private
|
||||
*/
|
||||
this._cursorIndex = 0;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this object is fixedToCamera then this stores the x/y offset that its drawn at, from the top-left of the camera view.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point();
|
||||
|
||||
/**
|
||||
* @property {boolean} enableBody - If true all Sprites created with `Group.create` or `Group.createMulitple` will have a physics body created on them. Change the body type with `Group.physicsBodyType`.
|
||||
*/
|
||||
this.enableBody = false;
|
||||
|
||||
/**
|
||||
* @property {number} physicsBodyType - If Group.enableBody is true this is the type of physics body that is created on new Sprites. Phaser.Physics.ARCADE, Phaser.Physics.P2, Phaser.Physics.NINJA, etc.
|
||||
*/
|
||||
this.physicsBodyType = Phaser.Physics.ARCADE;
|
||||
|
||||
/**
|
||||
* A small internal cache:
|
||||
* 0 = previous position.x
|
||||
|
@ -106,10 +110,11 @@ Phaser.Group = function (game, parent, name, addToStage) {
|
|||
* 5 = outOfBoundsFired (0 = no, 1 = yes)
|
||||
* 6 = exists (0 = no, 1 = yes)
|
||||
* 7 = fixed to camera (0 = no, 1 = yes)
|
||||
* 8 = cursor index
|
||||
* @property {Int16Array} _cache
|
||||
* @private
|
||||
*/
|
||||
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
|
||||
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0, 0]);
|
||||
|
||||
};
|
||||
|
||||
|
@ -262,6 +267,22 @@ Phaser.Group.prototype.create = function (x, y, key, frame, exists) {
|
|||
this.cursor = child;
|
||||
}
|
||||
|
||||
if (this.enableBody)
|
||||
{
|
||||
if (this.physicsBodyType === Phaser.Physics.ARCADE)
|
||||
{
|
||||
child.body = new Phaser.Physics.Arcade.Body(child);
|
||||
}
|
||||
else if (this.physicsBodyType === Phaser.Physics.NINJA && this.game.physics.ninja)
|
||||
{
|
||||
child.body = new Phaser.Physics.Ninja.Body(this.game.physics.ninja, child, 1);
|
||||
}
|
||||
else if (this.physicsBodyType === Phaser.Physics.P2 && this.game.physics.p2)
|
||||
{
|
||||
child.body = new Phaser.Physics.P2.Body(this.game, child, x, y, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
|
||||
}
|
||||
|
@ -298,16 +319,16 @@ Phaser.Group.prototype.next = function () {
|
|||
if (this.cursor)
|
||||
{
|
||||
// Wrap the cursor?
|
||||
if (this._cursorIndex === this.children.length)
|
||||
if (this._cache[8] === this.children.length)
|
||||
{
|
||||
this._cursorIndex = 0;
|
||||
this._cache[8] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cursorIndex++;
|
||||
this._cache[8]++;
|
||||
}
|
||||
|
||||
this.cursor = this.children[this._cursorIndex];
|
||||
this.cursor = this.children[this._cache[8]];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -322,16 +343,16 @@ Phaser.Group.prototype.previous = function () {
|
|||
if (this.cursor)
|
||||
{
|
||||
// Wrap the cursor?
|
||||
if (this._cursorIndex === 0)
|
||||
if (this._cache[8] === 0)
|
||||
{
|
||||
this._cursorIndex = this.children.length - 1;
|
||||
this._cache[8] = this.children.length - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cursorIndex--;
|
||||
this._cache[8]--;
|
||||
}
|
||||
|
||||
this.cursor = this.children[this._cursorIndex];
|
||||
this.cursor = this.children[this._cache[8]];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Javascript QuadTree
|
||||
* @version 1.0
|
||||
* @author Timo Hausmann
|
||||
*
|
||||
* @version 1.2, September 4th 2013
|
||||
* @author Richard Davey
|
||||
* The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
|
||||
* it massively to add node indexing, removed lots of temp. var creation and significantly
|
||||
* increased performance as a result.
|
||||
*
|
||||
* Original version at https://github.com/timohausmann/quadtree-js/
|
||||
*/
|
||||
|
||||
* Javascript QuadTree
|
||||
* @version 1.0
|
||||
* @author Timo Hausmann
|
||||
*
|
||||
* @version 1.2, September 4th 2013
|
||||
* @author Richard Davey
|
||||
* The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
|
||||
* it massively to add node indexing, removed lots of temp. var creation and significantly
|
||||
* increased performance as a result.
|
||||
*
|
||||
* Original version at https://github.com/timohausmann/quadtree-js/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @copyright © 2012 Timo Hausmann
|
||||
*
|
||||
|
@ -42,99 +42,170 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* QuadTree Constructor
|
||||
*
|
||||
* @class Phaser.QuadTree
|
||||
* @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts. However I've tweaked
|
||||
* it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result. Original version at https://github.com/timohausmann/quadtree-js/
|
||||
* @constructor
|
||||
* @param {Description} physicsManager - Description.
|
||||
* @param {Description} x - Description.
|
||||
* @param {Description} y - Description.
|
||||
* @param {number} width - The width of your game in game pixels.
|
||||
* @param {number} height - The height of your game in game pixels.
|
||||
* @param {number} maxObjects - Description.
|
||||
* @param {number} maxLevels - Description.
|
||||
* @param {number} level - Description.
|
||||
*/
|
||||
Phaser.QuadTree = function (physicsManager, x, y, width, height, maxObjects, maxLevels, level) {
|
||||
|
||||
this.physicsManager = physicsManager;
|
||||
this.ID = physicsManager.quadTreeID;
|
||||
physicsManager.quadTreeID++;
|
||||
* QuadTree Constructor
|
||||
*
|
||||
* @class Phaser.QuadTree
|
||||
* @classdesc A QuadTree implementation. The original code was a conversion of the Java code posted to GameDevTuts.
|
||||
* However I've tweaked it massively to add node indexing, removed lots of temp. var creation and significantly increased performance as a result.
|
||||
* Original version at https://github.com/timohausmann/quadtree-js/
|
||||
* @constructor
|
||||
* @param {number} x - The top left coordinate of the quadtree.
|
||||
* @param {number} y - The top left coordinate of the quadtree.
|
||||
* @param {number} width - The width of the quadtree in pixels.
|
||||
* @param {number} height - The height of the quadtree in pixels.
|
||||
* @param {number} [maxObjects=10] - The maximum number of objects per node.
|
||||
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
|
||||
* @param {number} [level=0] - Which level is this?
|
||||
*/
|
||||
Phaser.QuadTree = function(x, y, width, height, maxObjects, maxLevels, level) {
|
||||
|
||||
this.maxObjects = maxObjects || 10;
|
||||
this.maxLevels = maxLevels || 4;
|
||||
this.level = level || 0;
|
||||
/**
|
||||
* @property {number} maxObjects - The maximum number of objects per node.
|
||||
* @default
|
||||
*/
|
||||
this.maxObjects = 10;
|
||||
|
||||
this.bounds = {
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: width,
|
||||
height: height,
|
||||
subWidth: Math.floor(width / 2),
|
||||
subHeight: Math.floor(height / 2),
|
||||
right: Math.round(x) + Math.floor(width / 2),
|
||||
bottom: Math.round(y) + Math.floor(height / 2)
|
||||
};
|
||||
|
||||
this.objects = [];
|
||||
this.nodes = [];
|
||||
/**
|
||||
* @property {number} maxLevels - The maximum number of levels to break down to.
|
||||
* @default
|
||||
*/
|
||||
this.maxLevels = 4;
|
||||
|
||||
/**
|
||||
* @property {number} level - The current level.
|
||||
*/
|
||||
this.level = 0;
|
||||
|
||||
/**
|
||||
* @property {object} bounds - Object that contains the quadtree bounds.
|
||||
*/
|
||||
this.bounds;
|
||||
|
||||
/**
|
||||
* @property {array} objects - Array of quadtree children.
|
||||
*/
|
||||
this.objects;
|
||||
|
||||
/**
|
||||
* @property {array} nodes - Array of associated child nodes.
|
||||
*/
|
||||
this.nodes;
|
||||
|
||||
this.reset(x, y, width, height, maxObjects, maxLevels, level);
|
||||
|
||||
};
|
||||
|
||||
Phaser.QuadTree.prototype = {
|
||||
|
||||
/*
|
||||
* Split the node into 4 subnodes
|
||||
*
|
||||
* @method Phaser.QuadTree#split
|
||||
/**
|
||||
* Resets the QuadTree.
|
||||
*
|
||||
* @method Phaser.QuadTree#reset
|
||||
* @param {number} x - The top left coordinate of the quadtree.
|
||||
* @param {number} y - The top left coordinate of the quadtree.
|
||||
* @param {number} width - The width of the quadtree in pixels.
|
||||
* @param {number} height - The height of the quadtree in pixels.
|
||||
* @param {number} [maxObjects=10] - The maximum number of objects per node.
|
||||
* @param {number} [maxLevels=4] - The maximum number of levels to iterate to.
|
||||
* @param {number} [level=0] - Which level is this?
|
||||
*/
|
||||
split: function() {
|
||||
reset: function (x, y, width, height, maxObjects, maxLevels, level) {
|
||||
|
||||
this.level++;
|
||||
|
||||
// top right node
|
||||
this.nodes[0] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// top left node
|
||||
this.nodes[1] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom left node
|
||||
this.nodes[2] = new Phaser.QuadTree(this.physicsManager, this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom right node
|
||||
this.nodes[3] = new Phaser.QuadTree(this.physicsManager, this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
this.maxObjects = maxObjects || 10;
|
||||
this.maxLevels = maxLevels || 4;
|
||||
this.level = level || 0;
|
||||
|
||||
this.bounds = {
|
||||
x: Math.round(x),
|
||||
y: Math.round(y),
|
||||
width: width,
|
||||
height: height,
|
||||
subWidth: Math.floor(width / 2),
|
||||
subHeight: Math.floor(height / 2),
|
||||
right: Math.round(x) + Math.floor(width / 2),
|
||||
bottom: Math.round(y) + Math.floor(height / 2)
|
||||
};
|
||||
|
||||
this.objects = [];
|
||||
this.nodes = [];
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Insert the object into the node. If the node
|
||||
* exceeds the capacity, it will split and add all
|
||||
* objects to their corresponding subnodes.
|
||||
*
|
||||
/**
|
||||
* Populates this quadtree with the children of the given Group. In order to be added the child must exist and have a body property.
|
||||
*
|
||||
* @method Phaser.QuadTree#populate
|
||||
* @param {Phaser.Group} group - The Group to add to the quadtree.
|
||||
*/
|
||||
populate: function (group) {
|
||||
|
||||
group.forEach(this.populateHandler, this, true);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Handler for the populate method.
|
||||
*
|
||||
* @method Phaser.QuadTree#populateHandler
|
||||
* @param {Phaser.Sprite|object} sprite - The Sprite to check.
|
||||
*/
|
||||
populateHandler: function (sprite) {
|
||||
|
||||
if (sprite.body && sprite.exists)
|
||||
{
|
||||
this.insert(sprite.body);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Split the node into 4 subnodes
|
||||
*
|
||||
* @method Phaser.QuadTree#split
|
||||
*/
|
||||
split: function () {
|
||||
|
||||
this.level++;
|
||||
|
||||
// top right node
|
||||
this.nodes[0] = new Phaser.QuadTree(this.bounds.right, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// top left node
|
||||
this.nodes[1] = new Phaser.QuadTree(this.bounds.x, this.bounds.y, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom left node
|
||||
this.nodes[2] = new Phaser.QuadTree(this.bounds.x, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
// bottom right node
|
||||
this.nodes[3] = new Phaser.QuadTree(this.bounds.right, this.bounds.bottom, this.bounds.subWidth, this.bounds.subHeight, this.maxObjects, this.maxLevels, this.level);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Insert the object into the node. If the node exceeds the capacity, it will split and add all objects to their corresponding subnodes.
|
||||
*
|
||||
* @method Phaser.QuadTree#insert
|
||||
* @param {object} body - Description.
|
||||
* @param {Phaser.Physics.Arcade.Body|object} body - The Body object to insert into the quadtree. Can be any object so long as it exposes x, y, right and bottom properties.
|
||||
*/
|
||||
insert: function (body) {
|
||||
|
||||
|
||||
var i = 0;
|
||||
var index;
|
||||
|
||||
|
||||
// if we have subnodes ...
|
||||
if (this.nodes[0] != null)
|
||||
{
|
||||
index = this.getIndex(body);
|
||||
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
this.nodes[index].insert(body);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.objects.push(body);
|
||||
|
||||
|
||||
if (this.objects.length > this.maxObjects && this.level < this.maxLevels)
|
||||
{
|
||||
// Split if we don't already have subnodes
|
||||
|
@ -142,12 +213,12 @@ Phaser.QuadTree.prototype = {
|
|||
{
|
||||
this.split();
|
||||
}
|
||||
|
||||
|
||||
// Add objects to subnodes
|
||||
while (i < this.objects.length)
|
||||
{
|
||||
index = this.getIndex(this.objects[i]);
|
||||
|
||||
|
||||
if (index !== -1)
|
||||
{
|
||||
// this is expensive - see what we can do about it
|
||||
|
@ -161,27 +232,27 @@ Phaser.QuadTree.prototype = {
|
|||
}
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* Determine which node the object belongs to.
|
||||
*
|
||||
*
|
||||
* @method Phaser.QuadTree#getIndex
|
||||
* @param {object} rect - Description.
|
||||
* @param {Phaser.Rectangle|object} rect - The bounds in which to check.
|
||||
* @return {number} index - Index of the subnode (0-3), or -1 if rect cannot completely fit within a subnode and is part of the parent node.
|
||||
*/
|
||||
getIndex: function (rect) {
|
||||
|
||||
|
||||
// default is that rect doesn't fit, i.e. it straddles the internal quadrants
|
||||
var index = -1;
|
||||
|
||||
if (rect.x < this.bounds.right && rect.right < this.bounds.right)
|
||||
{
|
||||
if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
|
||||
if (rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)
|
||||
{
|
||||
// rect fits within the top-left quadrant of this quadtree
|
||||
index = 1;
|
||||
}
|
||||
else if ((rect.y > this.bounds.bottom))
|
||||
else if (rect.y > this.bounds.bottom)
|
||||
{
|
||||
// rect fits within the bottom-left quadrant of this quadtree
|
||||
index = 2;
|
||||
|
@ -190,76 +261,76 @@ Phaser.QuadTree.prototype = {
|
|||
else if (rect.x > this.bounds.right)
|
||||
{
|
||||
// rect can completely fit within the right quadrants
|
||||
if ((rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom))
|
||||
if (rect.y < this.bounds.bottom && rect.bottom < this.bounds.bottom)
|
||||
{
|
||||
// rect fits within the top-right quadrant of this quadtree
|
||||
index = 0;
|
||||
}
|
||||
else if ((rect.y > this.bounds.bottom))
|
||||
else if (rect.y > this.bounds.bottom)
|
||||
{
|
||||
// rect fits within the bottom-right quadrant of this quadtree
|
||||
index = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return index;
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
* Return all objects that could collide with the given object.
|
||||
*
|
||||
/**
|
||||
* Return all objects that could collide with the given Sprite.
|
||||
*
|
||||
* @method Phaser.QuadTree#retrieve
|
||||
* @param {object} rect - Description.
|
||||
* @Return {array} - Array with all detected objects.
|
||||
* @param {Phaser.Sprite} sprite - The sprite to check against.
|
||||
* @return {array} - Array with all detected objects.
|
||||
*/
|
||||
retrieve: function (sprite) {
|
||||
|
||||
|
||||
var returnObjects = this.objects;
|
||||
|
||||
sprite.body.quadTreeIndex = this.getIndex(sprite.body);
|
||||
|
||||
// Temp store for the node IDs this sprite is in, we can use this for fast elimination later
|
||||
sprite.body.quadTreeIDs.push(this.ID);
|
||||
// sprite.body.quadTreeIndex = this.getIndex(sprite.body);
|
||||
var index = this.getIndex(sprite.body);
|
||||
|
||||
if (this.nodes[0])
|
||||
{
|
||||
// if rect fits into a subnode ..
|
||||
if (sprite.body.quadTreeIndex !== -1)
|
||||
// If rect fits into a subnode ..
|
||||
if (index !== -1)
|
||||
{
|
||||
returnObjects = returnObjects.concat(this.nodes[sprite.body.quadTreeIndex].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[index].retrieve(sprite));
|
||||
}
|
||||
else
|
||||
{
|
||||
// if rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
|
||||
// If rect does not fit into a subnode, check it against all subnodes (unrolled for speed)
|
||||
returnObjects = returnObjects.concat(this.nodes[0].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[1].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[2].retrieve(sprite));
|
||||
returnObjects = returnObjects.concat(this.nodes[3].retrieve(sprite));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return returnObjects;
|
||||
|
||||
},
|
||||
|
||||
/*
|
||||
/**
|
||||
* Clear the quadtree.
|
||||
* @method Phaser.QuadTree#clear
|
||||
*/
|
||||
clear: function () {
|
||||
|
||||
this.objects = [];
|
||||
|
||||
for (var i = 0, len = this.nodes.length; i < len; i++)
|
||||
|
||||
this.objects.length = 0;
|
||||
|
||||
var i = this.nodes.length;
|
||||
|
||||
while (i--)
|
||||
{
|
||||
// if (typeof this.nodes[i] !== 'undefined')
|
||||
if (this.nodes[i])
|
||||
{
|
||||
this.nodes[i].clear();
|
||||
delete this.nodes[i];
|
||||
}
|
||||
this.nodes[i].clear();
|
||||
this.nodes.splice(i, 1);
|
||||
}
|
||||
|
||||
this.nodes.length = 0;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Phaser.QuadTree.prototype.constructor = Phaser.QuadTree;
|
||||
|
|
|
@ -47,12 +47,7 @@ Phaser.Physics.Arcade = function (game) {
|
|||
/**
|
||||
* @property {Phaser.QuadTree} quadTree - The world QuadTree.
|
||||
*/
|
||||
this.quadTree = new Phaser.Physics.Arcade.QuadTree(this, this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
|
||||
/**
|
||||
* @property {number} quadTreeID - The QuadTree ID.
|
||||
*/
|
||||
this.quadTreeID = 0;
|
||||
this.quadTree = new Phaser.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
|
||||
// Avoid gc spikes by caching these values for re-use
|
||||
|
||||
|
@ -170,7 +165,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
* A game object can only have 1 physics body active at any one time, and it can't be changed until the object is destroyed.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade#enable
|
||||
* @param {object|array|Phaser.Group} object - The game object to create the physics body on. Can also be an array of objects, a body will be created on every object in the array that has a body parameter.
|
||||
* @param {object|array|Phaser.Group} object - The game object to create the physics body on. Can also be an array or Group of objects, a body will be created on every child that has a `body` property.
|
||||
* @param {boolean} [children=true] - Should a body be created on all children of this object? If true it will propagate down the display list.
|
||||
*/
|
||||
enable: function (object, children) {
|
||||
|
@ -500,7 +495,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// What is the sprite colliding with in the quadtree?
|
||||
this.quadTree.clear();
|
||||
|
||||
this.quadTree = new Phaser.QuadTree(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
this.quadTree.reset(this.game.world.bounds.x, this.game.world.bounds.y, this.game.world.bounds.width, this.game.world.bounds.height, this.maxObjects, this.maxLevels);
|
||||
|
||||
this.quadTree.populate(group);
|
||||
|
||||
|
@ -905,7 +900,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// This is special case code that handles things like horizontal moving platforms you can ride
|
||||
if (body2.moves)
|
||||
{
|
||||
body1.x += body2.x - body2.preX;
|
||||
body1.x += body2.x - body2.prev.x;
|
||||
}
|
||||
}
|
||||
else if (!body2.immovable)
|
||||
|
@ -916,7 +911,7 @@ Phaser.Physics.Arcade.prototype = {
|
|||
// This is special case code that handles things like horizontal moving platforms you can ride
|
||||
if (body1.moves)
|
||||
{
|
||||
body2.x += body1.x - body1.preX;
|
||||
body2.x += body1.x - body1.prev.x;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue