1+ /// <reference path="../core/Point.ts" />
2+ /// <reference path="../core/Rectangle.ts" />
3+ /// <reference path="../core/Vec2.ts" />
14/// <reference path="../gameobjects/Sprite.ts" />
25/// <reference path="../Game.ts" />
36
@@ -89,23 +92,17 @@ module Phaser {
8992 */
9093 public worldView : Rectangle ;
9194
92- /**
93- * How many sprites will be rendered by this camera.
94- * @type {number }
95- */
96- public totalSpritesRendered : number ;
97-
9895 /**
9996 * Scale factor of the camera.
100- * @type {MicroPoint }
97+ * @type {Vec2 }
10198 */
102- public scale : MicroPoint = new MicroPoint ( 1 , 1 ) ;
99+ public scale : Vec2 = new Vec2 ( 1 , 1 ) ;
103100
104101 /**
105102 * Scrolling factor.
106103 * @type {MicroPoint }
107104 */
108- public scroll : MicroPoint = new MicroPoint ( 0 , 0 ) ;
105+ public scroll : Vec2 = new Vec2 ( 0 , 0 ) ;
109106
110107 /**
111108 * Camera bounds.
@@ -119,79 +116,27 @@ module Phaser {
119116 */
120117 public deadzone : Rectangle = null ;
121118
122- // Camera Border
123- public disableClipping : bool = false ;
124-
125- /**
126- * Whether render border of this camera or not. (default is false)
127- * @type {boolean }
128- */
129- public showBorder : bool = false ;
130-
131119 /**
132- * Color of border of this camera. (in css color string)
133- * @type {string }
120+ * Disable the automatic camera canvas clipping when Camera is non-Stage sized.
121+ * @type {Boolean }
134122 */
135- public borderColor : string = 'rgb(255,255,255)' ;
123+ public disableClipping : bool = false ;
136124
137125 /**
138126 * Whether the camera background is opaque or not. If set to true the Camera is filled with
139- * the value of Camera.backgroundColor every frame.
127+ * the value of Camera.backgroundColor every frame. Normally you wouldn't enable this if the
128+ * Camera is the full Stage size, as the Stage.backgroundColor has the same effect. But for
129+ * multiple or mini cameras it can be very useful.
140130 * @type {boolean }
141131 */
142132 public opaque : bool = false ;
143133
144134 /**
145- * Clears the camera every frame using a canvas clearRect call (default to true).
146- * Note that this erases anything below the camera as well, so do not use it in conjuction with a camera
147- * that uses alpha or that needs to be able to manage opacity. Equally if Camera.opaque is set to true
148- * then set Camera.clear to false to save rendering time.
149- * By default the Stage will clear itself every frame, so be sure not to double-up clear calls.
150- * @type {boolean }
151- */
152- public clear : bool = false ;
153-
154- /**
155- * Background color in css color string.
135+ * The Background Color of the camera in css color string format, i.e. 'rgb(0,0,0)' or '#ff0000'.
136+ * Not used if the Camera.opaque property is false.
156137 * @type {string }
157138 */
158- private _bgColor : string = 'rgb(0,0,0)' ;
159-
160- /**
161- * Background texture to be rendered if background is visible.
162- */
163- private _bgTexture ;
164-
165- /**
166- * Background texture repeat style. (default is 'repeat')
167- * @type {string }
168- */
169- private _bgTextureRepeat : string = 'repeat' ;
170-
171- // Camera Shadow
172- /**
173- * Render camera shadow or not. (default is false)
174- * @type {boolean }
175- */
176- public showShadow : bool = false ;
177-
178- /**
179- * Color of shadow, in css color string.
180- * @type {string }
181- */
182- public shadowColor : string = 'rgb(0,0,0)' ;
183-
184- /**
185- * Blur factor of shadow.
186- * @type {number }
187- */
188- public shadowBlur : number = 10 ;
189-
190- /**
191- * Offset of the shadow from camera's position.
192- * @type {MicroPoint }
193- */
194- public shadowOffset : MicroPoint = new MicroPoint ( 4 , 4 ) ;
139+ public backgroundColor : string = 'rgb(0,0,0)' ;
195140
196141 /**
197142 * Whether this camera visible or not. (default is true)
@@ -418,15 +363,6 @@ module Phaser {
418363 this . _sx = this . _stageX ;
419364 this . _sy = this . _stageY ;
420365
421- // Shadow
422- if ( this . showShadow == true )
423- {
424- this . _game . stage . context . shadowColor = this . shadowColor ;
425- this . _game . stage . context . shadowBlur = this . shadowBlur ;
426- this . _game . stage . context . shadowOffsetX = this . shadowOffset . x ;
427- this . _game . stage . context . shadowOffsetY = this . shadowOffset . y ;
428- }
429-
430366 // Scale on
431367 if ( this . scale . x !== 1 || this . scale . y !== 1 )
432368 {
@@ -445,32 +381,11 @@ module Phaser {
445381 this . _game . stage . context . translate ( - ( this . _sx + this . worldView . halfWidth ) , - ( this . _sy + this . worldView . halfHeight ) ) ;
446382 }
447383
448- if ( this . clear == true )
449- {
450- this . _game . stage . context . clearRect ( this . _sx , this . _sy , this . worldView . width , this . worldView . height ) ;
451- }
452-
453384 // Background
454- if ( this . opaque == true )
385+ if ( this . opaque )
455386 {
456- if ( this . _bgTexture )
457- {
458- this . _game . stage . context . fillStyle = this . _bgTexture ;
459- this . _game . stage . context . fillRect ( this . _sx , this . _sy , this . worldView . width , this . worldView . height ) ;
460- }
461- else
462- {
463- this . _game . stage . context . fillStyle = this . _bgColor ;
464- this . _game . stage . context . fillRect ( this . _sx , this . _sy , this . worldView . width , this . worldView . height ) ;
465- }
466- }
467-
468- // Shadow off
469- if ( this . showShadow == true )
470- {
471- this . _game . stage . context . shadowBlur = 0 ;
472- this . _game . stage . context . shadowOffsetX = 0 ;
473- this . _game . stage . context . shadowOffsetY = 0 ;
387+ this . _game . stage . context . fillStyle = this . backgroundColor ;
388+ this . _game . stage . context . fillRect ( this . _sx , this . _sy , this . worldView . width , this . worldView . height ) ;
474389 }
475390
476391 this . fx . render ( this , this . _stageX , this . _stageY , this . worldView . width , this . worldView . height ) ;
@@ -487,14 +402,6 @@ module Phaser {
487402 // Render all the Sprites
488403 this . _game . world . group . render ( this , this . _sx , this . _sy ) ;
489404
490- if ( this . showBorder == true )
491- {
492- this . _game . stage . context . strokeStyle = this . borderColor ;
493- this . _game . stage . context . lineWidth = 1 ;
494- this . _game . stage . context . rect ( this . _sx , this . _sy , this . worldView . width , this . worldView . height ) ;
495- this . _game . stage . context . stroke ( ) ;
496- }
497-
498405 // Scale off
499406 if ( this . scale . x !== 1 || this . scale . y !== 1 )
500407 {
@@ -520,28 +427,6 @@ module Phaser {
520427
521428 }
522429
523- public set backgroundColor ( color : string ) {
524-
525- this . _bgColor = color ;
526-
527- }
528-
529- public get backgroundColor ( ) : string {
530- return this . _bgColor ;
531- }
532-
533- /**
534- * Set camera background texture.
535- * @param key {string} Asset key of the texture.
536- * @param [repeat] {string} what kind of repeat will this texture used for background.
537- */
538- public setTexture ( key : string , repeat ?: string = 'repeat' ) {
539-
540- this . _bgTexture = this . _game . stage . context . createPattern ( this . _game . cache . getImage ( key ) , repeat ) ;
541- this . _bgTextureRepeat = repeat ;
542-
543- }
544-
545430 /**
546431 * Set position of this camera.
547432 * @param x {number} X position.
0 commit comments