hexonaut / haxe-phaser

Haxe externs for Phaser.
MIT License
51 stars 9 forks source link

Inheritance problem in function Game.add.image #12

Closed plicatibu closed 10 years ago

plicatibu commented 10 years ago

The official example example of Phaser named Display: alpha mask works perfectly and without any warning / error.

But it's version converted to Haxe generates the error message

phaser.gameobjects.BitmapData should be phaser.gameobjects.RenderTexture for function argument 'key'

I don't know for sure whether it's a problem with conversion from JS to Haxe or whether it's a problem in the official example of Phaser, but my guess is that it's something related to the way JS works that was not implemented in the Haxe biding.

Original JS code:

//  Create a new bitmap data the same size as our picture
var bmd = game.make.bitmapData(320, 256);

//  And create an alpha mask image by combining pic and mask from the cache
bmd.alphaMask('pic', 'mask');

//  A BitmapData is just a texture. You need to apply it to a sprite or image
//  to actually display it:
game.add.image(game.world.centerX, 320, bmd).anchor.set(0.5, 0);

Converted code to Haxe:

//  Create a new bitmap data the same size as our picture
var bmd:BitmapData = game.make.bitmapData(320, 256);

//  And create an alpha mask image by combining pic and mask from the cache
bmd.alphaMask('pic', 'mask');

//  A BitmapData is just a texture. You need to apply it to a sprite or image
//  to actually display it:
game.add.image(game.world.centerX, 320, bmd).anchor.set(0.5, 0);
plicatibu commented 10 years ago

The same compiler error happens in the official Phaser example named Display: bitmapdata draw

Orignal JS code:

function create() {

    bmd = game.add.bitmapData(800, 600);

    bmd.context.fillStyle = 'rgba(255, 0, 0, 0.3)';

    //  Add the bmd as a texture to an Image object.
    //  If we don't do this nothing will render on screen.
    game.add.sprite(0, 0, bmd);

}

Code in Haxe:

    function create()
    {
        bmd = game.add.bitmapData(800, 600);

        bmd.context.fillStyle = 'rgba(255, 0, 0, 0.3)';

        //  Add the bmd as a texture to an Image object.
        //  If we don't do this nothing will render on screen.
        game.add.sprite(0, 0, bmd);
    }