PhaserEditor2D / PhaserEditor

A friendly IDE to develop HTML5 games based on the Phaser framework.
https://phasereditor2d.com
Eclipse Public License 1.0
330 stars 45 forks source link

Generated typescript creates compile error when setting scale on bitmaptext #119

Closed bfountaine closed 5 years ago

bfountaine commented 5 years ago

Version

Enter the version of Phaser Editor you're using. You can find this information on the main menu Help > About. -->

Description

Added a bitmapText item to my design. Set the scale to 2, generated the following line of code:

_score.scale.setTo(2.0, 2.0);

which causes the compile error: Property 'setTo' does not exist on type 'Point'

Possible solution

PhaserEditor2D commented 5 years ago

Hi, I am traveling, I should back to office in a week. Sorry.

PhaserEditor2D commented 5 years ago

Hi, I am back, I will take a look at this issue.

PhaserEditor2D commented 5 years ago

Hi, the TypeScript compiler is emitting that error because the type defs of the BitmapText class is missing the scale property. What the compiler sees is a scale of type PIXI.Point, inherited from PIXI.DisplayObject. We are going to change the Scene compiler to use the scale.set (available in PIXI.Point and Phaser.Point point classes) method instead of scale.setTo (only available in Phaser.Point).

In the meantime, you can use this PIXI defs (pixi.comments.d.ts) I attach here, to avoid the error. I declared the setTo method in the PIXI.Point.

pixi.comments.d.zip

Uncompress it and replace that file in your project.