Jump to content

Some issues with WebGL


Ninjadoodle
 Share

Recommended Posts

Hi @enpu

Just wanted to point out a couple of possible issues with WebGL.

Polygons don't seem to show and neither do tiled backgrounds. Everything works fine in canvas.

My Triangle Class ...

game.createClass('ShapeTriangle', {

    init: function(x, y, w, h, rot, color) {
        
        this.spriteLine = new game.Graphics();
        this.spriteLine.lineColor = '#000000';
        this.spriteLine.lineWidth = 2;
        this.spriteLine.fillAlpha = 0;
        this.spriteLine.drawPolygon([0, h, w, h, 0, 0]);
        this.spriteLine.anchor.set(w/2, h/2);
        this.spriteLine.position.set(x, y);
        this.spriteLine.rotation = rot * Math.PI;
        this.spriteLine.addTo(game.scene.robotContainer);
        
        this.spriteFill = new game.Graphics();
        this.spriteFill.fillColor = color;
        this.spriteFill.drawPolygon([0, h, w, h, 0, 0]);
        this.spriteFill.anchor.set(w/2, h/2);
        this.spriteFill.position.set(x, y);
        this.spriteFill.rotation = rot * Math.PI;
        this.spriteFill.addTo(game.scene.robotContainer);
    }
});

My Tiled Bg Class ...

game.createClass('Bg', {

    init: function(image) {
        
        this.sprite = new game.TilingSprite(image, game.system.width, game.system.height);
        this.sprite.anchorCenter();
        this.sprite.position.set(game.system.originalWidth / 2, game.system.originalHeight / 2);
        this.sprite.addTo(game.scene.bg);
    }
});

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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