Jump to content

Problems with correct rendering


Maxxis
 Share

Recommended Posts

Hello folks, 

I am trying to make specific game with Phaser 2. I am creating rectangles with numbers inside of it. I create 3 "layers" of objects: grid, blocks and digits. Grid and digits must be under  the blocks. When we make zoom in , blocks becaming transparent. 

I have 2 problems:

At start I can see my grid ( I don't need to see it at default zoom, because blocks are not transparent)
Grid in some places is thinner or thicker.
Here is my code and screens.

Can you, please, tell me how to solve that issues?
Thank you!

 

 var i, j, block, square, text, x, y, data,lines;

       
        var squareBitmap = this.add.bitmapData(this.BLOCK_SIZE + 4, this.BLOCK_SIZE + 4);
        var squareBitmap2 = this.add.bitmapData(this.BLOCK_SIZE + 4, this.BLOCK_SIZE + 4);
        squareBitmap.ctx.lineWidth = 0;

        squareBitmap2.ctx.lineWidth = 1;
      
        squareBitmap2.ctx.strokeRect(0, 0, GameApp.BootAndGo.BLOCK_SIZE + 4, GameApp.BootAndGo.BLOCK_SIZE + 4);

        for (i = 0; i < this.rows; i++) {
            for (j = 0; j < this.cols; j++) {
            
                squareBitmap.ctx.fillStyle = GameApp.BootAndGo.GRAY_COLORS[cartoon[i][j]];
                squareBitmap.ctx.fillRect(0, 0, this.BLOCK_SIZE + 4, this.BLOCK_SIZE + 4);
                x = 36 + j * (this.BLOCK_SIZE + 4);
                y = 150 + i * (this.BLOCK_SIZE + 4);

                line = this.add.sprite(x, y, squareBitmap2);
                line.anchor.setTo(0.5);
                line.smoothed = false;
             
                text = this.add.text(x, y, "" + cartoon[i][j], style);
                text.anchor.setTo(0.5);
                text.alpha = cartoon[i][j] == 0 ? 0 : 1;
                text.num = cartoon[i][j];
                square = this.add.sprite(x, y, squareBitmap);
                square.anchor.setTo(0.5);
                square.alpha = cartoon[i][j] == 0 ? 0 : 1;
                square.smoothed = false;
                line.alpha = cartoon[i][j] == 0 ? 0 : 1;

             

                square.val = cartoon[i][j];
                this.boardblocks.add(line);
                this.boardblocks.add(text);
                this.boardblocks.add(square);
              
                
        this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
        this.scale.pageAlignHorizontally = true;
        this.scale.pageAlignVertically = true;
        this.game.stage.smoothed = false;

 

ScreenShot.PNG

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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