a89529294 Posted December 4, 2018 Share Posted December 4, 2018 Right now I'm trying to create a mask effect where once you click on a ticket that part gets erased. var ticketBackground = this.add.image(....) var ticketForeground = this.add.image(....) var ticketResult = this.add.image(...) var shape= this.make.graphics(); var mask= shape.createGeometryMask(); ticketResult.setMask(mask); .... //x,y are positions of the user's mouse shape.fillRect( x - coinWidth / 2, y - coinWidth / 2 , coinWidth, coinWidth ) So I'm creating a bunch of rectangles to reveal the erased parts, but it gets really laggy when I try to play the game on android. It's fine on pc however. What I'm wondering is whether there is a better way to do this. Here is the game https://condescending-euclid-58185d.netlify.com/ Link to comment Share on other sites More sharing options...
prob Posted December 4, 2018 Share Posted December 4, 2018 This may be a better way, if it's what you're looking for: a89529294 and foukenma 1 1 Link to comment Share on other sites More sharing options...
Telinc1 Posted December 4, 2018 Share Posted December 4, 2018 Keep in mind that Graphics objects are redrawn every frame. You don't see it directly but rendering a masked object requires rendering its mask, too. The code snippet you've posted doesn't make it immediately obvious how often you add new circles, but it's probably quite often if you're doing in an input event handler. This is likely the cause for the lag since you'll quickly reach hundreds of circles. The solution prob proposed uses a Render Texture instead of a Graphics object. Render Textures aren't cleared unless you do it yourself, so it should be quite a bit more efficient. The code in that post uses a Bitmap Mask, which is only available on WebGL, but you might still be able to use a normal Geometry Mask. I can't check the code for you right now, but I can't recall anything which would require a Graphics object. a89529294 1 Link to comment Share on other sites More sharing options...
a89529294 Posted December 7, 2018 Author Share Posted December 7, 2018 Thanks for the answer guys. I tried the solution but the issue is still there. I noticed that the ticketbackground image, ticketforeground image and ticketResult image kept flickering while on android chrome, but not on pc nor ios safari. Can anyone take a look at the game on android for me? It was especially bad when you select the 4 tickets option. Link to comment Share on other sites More sharing options...
Recommended Posts