From 84741f065fb58edfbc38dc0a741242293915f180 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 12 Mar 2014 16:33:53 +0000 Subject: [PATCH] New P2 examples. And fixed Camera.atLimit value. --- examples/assets/sprites/diamonds32x24x5.png | Bin 0 -> 3327 bytes examples/p2 physics/impact events.js | 82 ++++++++++++++++++ examples/p2 physics/thrust.js | 65 +++++++++++++++ examples/p2 physics/world move.js | 88 ++++++++++++++++++++ src/core/Camera.js | 8 +- src/core/Group.js | 9 +- src/gameobjects/TileSprite.js | 2 +- src/physics/p2/World.js | 6 +- 8 files changed, 249 insertions(+), 11 deletions(-) create mode 100644 examples/assets/sprites/diamonds32x24x5.png create mode 100644 examples/p2 physics/impact events.js create mode 100644 examples/p2 physics/thrust.js create mode 100644 examples/p2 physics/world move.js diff --git a/examples/assets/sprites/diamonds32x24x5.png b/examples/assets/sprites/diamonds32x24x5.png new file mode 100644 index 0000000000000000000000000000000000000000..94c2d21dde8186fa9088a1f3345e012a58588665 GIT binary patch literal 3327 zcmaJ^c{r478y~VSXY5p#F{0r!#u(d7jD0O@M3QNYY0POhGlSuvk|ky7lqC*Egk+0Q zol|789LiFJqa=#5l_iWM-_UZ-cU`CNy{`AYpXa`Rzu$d7_jCXACb_#hNQ&(e0{{S$ zPL8&oJX^qfl|+Pi-{?atMm)2VY3Iv4NIlLB$I|fts~~D19^^#E67ZgQY*0i<2i^<- z*r87J@@4wE96;fyWIgN_Mvq0N@z?->nFWi6#ht)2L4kMzkzx*h|3?!TL<}+q`xv?C zyU=X#!9>SMI{sj!s~0Zv1P&Plwm^f-SSX$V8PCLmSY#4~fnu41w{=mx^_Ck325m!_ zC(OZLit=@F2iZ{Rc#x5v5frCy00)^M_25Q^NH|;0#A7jI_{4rVfGC>Sg}JX|jvp+}_?U~nW73DY-#85lr$2q+_h!o;$m z6o$q(1zS7=M<>#lL@EWerHBorhBD2;yh^_uflT`@OJRI%6R%+~7M2Es>*;SD=^N0+ z<^My; z?GRQ-q@g{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kT0_%UJmSqiT43~u#&lCY|Q zEvZMjY1UM@S0q0_?15{s%KOs6lOz6Q<)zl^fq~=dsxr1Dw+2n+H-KHu4=hgQhGhU( z9yW&1EHowY?qQ4dXP!l%5o`B<5dk-JWDbzT?LCVhX8ryOQGaMA6jeIAwl}&SV<|8| zE>mcjYLnNz@N>U=!JfgrNvlT}vc;}D63u(KYRc8()t|oac^h3_dwn8g|*;% zUQnBTWW0Psrlk$nmF!*B&EH~O6U?3?55%Qufep}qOhkfmkNRG%pGv=fD~ph2bHiOi z+3+)BtSISha++V2BIoh&s8EM+l)TH}+&b=xk_hn=f#V=6y;H5;9~QTY9>M(86ln&X z&l}0w_~Z)_vfj0sJ^$F&w#@-LC_a|XHyyG^ZT{(e=*mWoyF}doD3<|SpEg-s?BTR; z4oQbp>@!tO{mf|M?7s z)VLieT!dtd?j+r0zCF-OyaOMSq>eJfp>8ocN(=o9F2Z$fBP zYkA<`vQ)+L6z&JX;5x@!+tkX-iavg(GC#e2{h^$yCO*wo##!!Bj}{Ni$u+&$qaUK( zr==~4nUjJlPQ<5OywE5JcX4G#l_Wjn3Qq6QtU>hAJp#B8(WxU+eXniX2|2fK*iG-j zujd~voG83I?;-Q#7O12nDYeHiB)iR7{{Bgd%h}BHiyQ|h$I;l!T63gL2TT5NC4>?(>Vi zhBq_zyISgi>^!E|n%`u`m1I{guK6Gdy_V++`Q9}R zkWZen&*JVgfuMhGUtAPxV}6X|RK|`Mh3Ueoj~ys=gFM&yXQ)1Ed`aLe2Pn*pJ9;`z z%tE$e%P=`q+bg!%_(E9a&g^Vw37C7@!qTT~<8w8%YA zeNvQGT!6NcFub(AywjVttd6 this.bounds.right) + if (this.view.right >= this.bounds.right) { this.atLimit.x = true; this.view.x = this.bounds.right - this.width; } - if (this.view.y < this.bounds.top) + if (this.view.y <= this.bounds.top) { this.atLimit.y = true; this.view.y = this.bounds.top; } - if (this.view.bottom > this.bounds.bottom) + if (this.view.bottom >= this.bounds.bottom) { this.atLimit.y = true; this.view.y = this.bounds.bottom - this.height; diff --git a/src/core/Group.js b/src/core/Group.js index 85c6a5804..df217d96a 100644 --- a/src/core/Group.js +++ b/src/core/Group.js @@ -289,15 +289,18 @@ Phaser.Group.prototype.create = function (x, y, key, frame, exists) { { if (this.physicsBodyType === Phaser.Physics.ARCADE) { - child.body = new Phaser.Physics.Arcade.Body(child); + this.game.physics.arcade.enable(child); + // 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); + this.game.physics.ninja.enable(child); + // child.body = new Phaser.Physics.Ninja.Body(this.game.physics.ninja, child, 1); } else if (this.physicsBodyType === Phaser.Physics.P2JS && this.game.physics.p2) { - child.body = new Phaser.Physics.P2.Body(this.game, child, x, y, 1); + this.game.physics.p2.enable(child); + // child.body = new Phaser.Physics.P2.Body(this.game, child, x, y, 1); } } diff --git a/src/gameobjects/TileSprite.js b/src/gameobjects/TileSprite.js index aac98731a..b7de22443 100644 --- a/src/gameobjects/TileSprite.js +++ b/src/gameobjects/TileSprite.js @@ -6,7 +6,7 @@ /** * A TileSprite is a Sprite that has a repeating texture. The texture can be scrolled and scaled and will automatically wrap on the edges as it does so. -* Please note that TileSprites have no input handler or physics bodies. +* Please note that TileSprites, as with normal Sprites, have no input handler or physics bodies by default. Both need enabling. * * @class Phaser.TileSprite * @constructor diff --git a/src/physics/p2/World.js b/src/physics/p2/World.js index d7d4ae061..14b4f138f 100644 --- a/src/physics/p2/World.js +++ b/src/physics/p2/World.js @@ -130,9 +130,9 @@ Phaser.Physics.P2 = function (game, config) { } // Hook into the World events - this.world.on("postStep", this.postStepHandler, this); - this.world.on("postBroadphase", this.postBroadphaseHandler, this); - this.world.on("impact", this.impactHandler, this); + // this.world.on("postStep", this.postStepHandler, this); + // this.world.on("postBroadphase", this.postBroadphaseHandler, this); + // this.world.on("impact", this.impactHandler, this); this.world.on("beginContact", this.beginContactHandler, this); this.world.on("endContact", this.endContactHandler, this);