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

Basic bitmapData not working


pistacchio
 Share

Recommended Posts

Hi,

I can't get this very basic example working. It shows a black screen while i'd expect a white rectangle on it. Any help?

var GAME_W           = 800,    GAME_Y           = 600,    GRID_SIZE_W      = 10,    GRID_SIZE_H      = 20,    GRID_CELL_SIZE   = 20,    PLASMA_CELL_SIZE = 4,    game = new Phaser.Game(GAME_W, GAME_Y),    Game = {};// MAIN STATEGame.Main = function (game) {    this.backgroundData = null;}Game.Main.prototype = {    create: function () {        this.backgroundData = this.add.bitmapData(GRID_SIZE_W * GRID_CELL_SIZE / PLASMA_CELL_SIZE, GRID_SIZE_H * GRID_CELL_SIZE / PLASMA_CELL_SIZE);        this.backgroundData.fill(1, 1, 1, 1);        this.add.image(0, 0, this.backgroundData).anchor.set(0.5, 0.5);    }// GAME SETUPgame.state.add('Main', Game.Main);game.state.start('Main');
Link to comment
Share on other sites

To expand on what Rich said, the problem is you're filling the bitmapdata with rgba(1,1,1,1), which is almost black.  You should change

this.backgroundData.fill(1, 1, 1, 1);

to

this.backgroundData.fill(255, 255, 255, 1);

It seems bitmapdata.fill uses integers from 0 to 255 rather than floats from 0 to 1 for colors.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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