Jump to content

Phaser 2.4.3-RC1 Released


Recommended Posts

Today we've released Phaser 2.4.3 RC1 and we'd greatly appreciate any time you can spend helping to test it.



As to be expected there are a bunch of bug fixes and updates. However we also found time to add some nice **new features** too:


* Loader.images is a new method that allows you to pass an array of image keys, and optionally the urls, to the Loader and have them all added to the load queue in one go.

* TweenManager.frameBased allows you to control if all newly created Tweens update based on the physics step (i.e. frame based) or the system clock (time based). A frame based tween will use the physics elapsed timer when updating. This means it will retain the same consistent frame rate, regardless of the speed of the device. The duration value given should be given in frames. If the Tween uses a time based update (which is the default) then the duration is given in milliseconds. In this situation a 2000ms tween will last exactly 2 seconds, regardless of the device and how many visual updates the tween has actually been through.

* Tween.frameBased does the same as TweenManager.frameBased but allows you to set the value on a per-tween basis.

* BitmapText.smoothed is a new boolean property that allows you to set texture smoothing on a bitmap font or not. By default smoothing is always on, but you can turn it off which helps for bitmap fonts created from pixel art style character sets.

* Text.addFontStyle and Text.addFontWeight allow you to apply font weights and styles to specific characters in a Text object. For example you can now include bold or italics within single Text objects (thanks @jdnichollsc #1950)

* PIXI.CanvasPool is a new static global created to deal with the issue of resource leaks and continuous DOM node build-up when creating lots of Text or BitmapData objects, or when calling `generateTexture` on any display object. The CanvasPool will do its best to re-use out dated canvas elements rather than filling up the DOM with new ones.

* Sprite.setTexture has a new `destroyBase` parameter - set this to `true` if you know the base used a generated texture that isn't being used by any other sprites. This will free-up the canvas for further re-use by other calls to generateTexture or Text objects.

* Line.midPoint will return a Point object where the x and y values correspond to the center (or midpoint) of the Line segment.

* Line.rotateAround allows you to rotate a Line around the given coordinates (in world space)

* Line.centerOn will position the Line so that its midpoint lays on the coordinates given.

* BitmapData.line draws a line to the BitmapData in the color and thickness specified.

* BitmapData.op is a handy short-code to get and set the canvas global composite operator.

* BitmapData.drawFull draws the given Game Object or Group to a BitmapData and then recursively iterates through all of its children, including children of Game Objects and Groups. It can draw Text, BitmapText, Sprites, Images, Emitters and Graphics objects. It's perfectly valid to pass in `game.world` as the parent object, and it will iterate through the entire display list.


If you find any issues please either post in this forum thread or add them to the Github Issues.



Link to comment
Share on other sites

Any changes to Scale Manager? When I update from 2.4.2 to 2.4.3 the game is no longer centered (because I had margin: 0; to CSS). If I remove margin: 0 the game is centered but a vertical scroll bar appears and when inspecting the element in chrome the canvas margin appears to be wrongly set. There is an empty row below the canvas that makes the scroll appear.

Link to comment
Share on other sites

Hey Rich, thanks - awesome update. 


Currently using this for ludum dare 33 (will post some code afterwards) but I am noticing that "justpressed" is not working as it use to (even breaking the examples: http://phaser.io/examples/v2/input/keyboard-justpressed). 


Any tips on getting it working?





Got it working, missed it in the doco's - was working off the examples (which were broken in this case). 

Edited by cjke
Link to comment
Share on other sites

Nice!  ;)


With  Text.addFontStyle and Text.addFontWeight you can simulate markdown easily http://codepen.io/jdnichollsc/pen/pJqadN



var playState: {    create: function(){      this.hello = this.game.add.text(this.game.world.centerX, this.game.world.centerY, "Hello **World**, this is **MarkDown** in *Phaser*!", {        font: "bold 60px Arial",         align: "center",         wordWrap: true,        wordWrapWidth: 700      });      this.hello.anchor.set(0.5);      this.hello.addFontWeight('normal', 0);      this.hello.applyMarkdown();    }};Phaser.Text.prototype.applyMarkdown = function () {    var boldPositions = [];    var italicPositions = [];    var i = this.text.indexOf("**");    while(i >= 0){      this.text = this.text.substr(0, i) + this.text.substr(i+2);      boldPositions.push(i);      i = this.text.indexOf("**");    }    i = this.text.indexOf("*");    while(i >= 0){      this.text = this.text.substr(0, i) + this.text.substr(i+1);      italicPositions.push(i);            for (var j = 0; j < boldPositions.length; j++) {         if(i < boldPositions[j]) boldPositions[j]--;      }            i = this.text.indexOf("*");    }    for (i = 0; i < boldPositions.length; i=i+2) {         this.addFontWeight('bold', boldPositions[i]);        this.addFontWeight('normal', boldPositions[i+1]);    }    for (i = 0; i < italicPositions.length; i=i+2) {         this.addFontStyle('italic', italicPositions[i]);        this.addFontStyle('normal', italicPositions[i+1]);    }};
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...