pistacchio Posted September 17, 2015 Share Posted September 17, 2015 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 More sharing options...
rich Posted September 17, 2015 Share Posted September 17, 2015 The answer is in the docs for the BitmapData.fill parameters MichaelD 1 Link to comment Share on other sites More sharing options...
Cudabear Posted September 17, 2015 Share Posted September 17, 2015 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 changethis.backgroundData.fill(1, 1, 1, 1);tothis.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 More sharing options...
pistacchio Posted September 18, 2015 Author Share Posted September 18, 2015 For some reason I was assuming that the colors where in the 0-1 range. Silly me. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts