Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Problem Creating Dynamic Sprites


xyrix
 Share

Recommended Posts

Hi, I have code along the lines of:

 

bmd = game.add.bitmapData(100, 100);

bmd.fillColor(0xFFFFFF);

bmd.rect(0, 0, 100, 100);

 

sprite = game.add.sprite(0, 0, bmd);

 

I expect to see from this a white rectangle in the top left of my screen, but do not :-/. The documentation states that BitmapData as a class is experimental and subject to change, and the bitmap wobble demo does not work on either of my browsers (Chromium and Firefox latest versions for Linux).

 

I'm wondering where the problem lies - do I have the incorrect idea for using this part of the API?

Thanks in advance for any help :-).

Link to comment
Share on other sites

Hi,

 

Thanks for the fast reply!

I looked back at the API and found the function I used was called "fillStyle" not "fillColor", so that was wrong, too. I've now tried changing it to:

 

var bmd = game.add.bitmapData(100, 100);
bmd.fillStyle('#ffffff');
bmd.rect(0, 0, 100, 100);
sprite = game.add.sprite(0, 0, bmd);

 

Still, though, nothing gets drawn.

 

In case it's of any use, here is a version of the full code I expect to draw a rectangle but that does not:

 

 

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { create: create });

function create() {
        var bmd = game.add.bitmapData(100, 100);
        bmd.fillStyle('#ffffff');
        bmd.rect(0, 0, 100, 100);
        sprite = game.add.sprite(0, 0, bmd);
}

 

 

Hopefully there is something obvious I've overlooked :).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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