Skip to content

Commit c40c140

Browse files
committed
Camera.roundPx is a new boolean. If set to true it will call view.floor as part of its update loop, keeping its boundary to integer values. Set to false to disable this from happening (phaserjs#1141)
1 parent 79d873f commit c40c140

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Finally the list of [community authored Phaser Tutorials](http://www.lessmilk.co
6464

6565
## Change Log <a name="change-log"></a>
6666

67-
Version 2.1.0 - "Cairhien" - -in development-
67+
Version 2.1.0 - "Cairhien" - 9th September 2014
6868

6969
### New Features
7070

@@ -113,6 +113,7 @@ Version 2.1.0 - "Cairhien" - -in development-
113113
* The StateManager will now check if a State has a method called `resize`. If it does, and if the game is running in the RESIZE Scale Mode then this method will be called whenever the game resizes. It will be passed two parameters: `width` and `height` that will match the games new dimensions. Resizing can happen as a result of either the parent container changing shape, or the browser window resizing.
114114
* Rectangle.topRight returns a Point object that represents the top-right coordinate of the Rectangle.
115115
* The grunt script now builds a new version of Phaser without any physics (including Arcade Physics), Tilemaps or Particles. This build is called `phaser-no-physics.js` and works stand-alone. Please note that things like the GameObjectFactory aren't changed, so they will still try and create a Tilemap for example should you ask them to (thanks @eguneys #1172)
116+
* Camera.roundPx is a new boolean. If set to `true` it will call `view.floor` as part of its update loop, keeping its boundary to integer values. Set to `false` to disable this from happening (#1141)
116117

117118
### Updates
118119

@@ -153,8 +154,8 @@ Version 2.1.0 - "Cairhien" - -in development-
153154
* BitmapData.copyPixels is now called BitmapData.copyRect and the method signature has changed.
154155
* BitmapData.draw method signature has changed significantly.
155156
* Phaser.Canvas.getSmoothingEnabled will return `true` if the given context has image smoothing enabled, otherwise `false`.
156-
* Math.numberArray used to include the `max` value in the output but no longer does. Please take this into account if you use it in your code anywhere.
157-
* Math.numberArray has been updated to now include a `step` parameter. It will create arrays of values between min/max (excluding max) with an optional step value (thanks @codevinsky #1170)
157+
* Math.numberArrayStep is a new method that allows you to return an array of numbers from `min` to `max` including an optional `step` parameter (thanks @codevinsky #1170)
158+
* Removed redundant `if` check from StateManager.preUpdate (thanks @FedeOmoto #1173)
158159

159160
### Bug Fixes
160161

build/phaser.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,7 @@ declare module Phaser {
13881388
id: number;
13891389
game: Phaser.Game;
13901390
height: number;
1391+
roundPx: boolean;
13911392
scale: Phaser.Point;
13921393
screenView: Phaser.Rectangle;
13931394
target: Phaser.Sprite;
@@ -3396,6 +3397,7 @@ declare module Phaser {
33963397
bounds: Phaser.Physics.P2.Body;
33973398
boundsCollidesWith: Phaser.Physics.P2.Body[];
33983399
boundsCollisionGroup: Phaser.Physics.P2.CollisionGroup;
3400+
config: any;
33993401
contactMaterial: Phaser.Physics.P2.ContactMaterial;
34003402
emitImpactEvent: boolean;
34013403
enableBodySleeping: boolean;

src/core/Camera.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ Phaser.Camera = function (game, id, x, y, width, height) {
6868
*/
6969
this.visible = true;
7070

71+
/**
72+
* @property {boolean} roundPx - If a Camera has roundPx set to `true` it will call `view.floor` as part of its update loop, keeping its boundary to integer values. Set this to `false` to disable this from happening.
73+
* @default
74+
*/
75+
this.roundPx = true;
76+
7177
/**
7278
* @property {boolean} atLimit - Whether this camera is flush with the World Bounds or not.
7379
*/
@@ -224,7 +230,10 @@ Phaser.Camera.prototype = {
224230
this.checkBounds();
225231
}
226232

227-
this.view.floor();
233+
if (this.roundPx)
234+
{
235+
this.view.floor();
236+
}
228237

229238
this.displayObject.position.x = -this.view.x;
230239
this.displayObject.position.y = -this.view.y;

0 commit comments

Comments
 (0)