@@ -27,6 +27,9 @@ module Phaser {
2727
2828 super ( game ) ;
2929
30+ this . canvas = game . stage . canvas ;
31+ this . context = game . stage . context ;
32+
3033 this . bounds = new Rectangle ( x , y , width , height ) ;
3134 this . exists = true ;
3235 this . active = true ;
@@ -126,7 +129,6 @@ module Phaser {
126129 */
127130 public static ALIGN_BOTTOM_RIGHT : number = 8 ;
128131
129-
130132 /**
131133 * Enum value for outOfBoundsAction. Stop the object when is out of world bounds.
132134 * @type {number }
@@ -139,12 +141,28 @@ module Phaser {
139141 */
140142 public static OUT_OF_BOUNDS_KILL : number = 1 ;
141143
144+ /**
145+ * A reference to the Canvas this GameObject will render to
146+ * @type {HTMLCanvasElement }
147+ */
148+ public canvas : HTMLCanvasElement ;
149+
150+ /**
151+ * A reference to the Canvas Context2D this GameObject will render to
152+ * @type {CanvasRenderingContext2D }
153+ */
154+ public context : CanvasRenderingContext2D ;
155+
142156 /**
143157 * Position of this object after scrolling.
144158 * @type {MicroPoint }
145159 */
146160 public _point : MicroPoint ;
147161
162+ /**
163+ * An Array of Cameras to which this GameObject won't render
164+ * @type {Array }
165+ */
148166 public cameraBlacklist : number [ ] ;
149167
150168 /**
@@ -352,8 +370,6 @@ module Phaser {
352370 */
353371 public preUpdate ( ) {
354372
355- // flicker time
356-
357373 this . last . x = this . bounds . x ;
358374 this . last . y = this . bounds . y ;
359375
@@ -761,6 +777,18 @@ module Phaser {
761777
762778 }
763779
780+ /**
781+ * Set the world bounds that this GameObject can exist within based on the size of the current game world.
782+ *
783+ * @param action {number} The action to take if the object hits the world bounds, either OUT_OF_BOUNDS_KILL or OUT_OF_BOUNDS_STOP
784+ */
785+ public setBoundsFromWorld ( action ?: number = GameObject . OUT_OF_BOUNDS_STOP ) {
786+
787+ this . setBounds ( this . _game . world . bounds . x , this . _game . world . bounds . y , this . _game . world . bounds . width , this . _game . world . bounds . height ) ;
788+ this . outOfBoundsAction = action ;
789+
790+ }
791+
764792 /**
765793 * If you do not wish this object to be visible to a specific camera, pass the camera here.
766794 *
0 commit comments