mwatt Posted October 7, 2013 Share Posted October 7, 2013 So, like the title says. A simplified version of the code I am trying to use looks like this: var graphics = new PIXI.Graphics();...... draw some stuff ......graphics.clear(); In reality, things are a bit more complicated than I show above, so it might be a problem that I am causing. I don't see how though, so I thought I would post and ask:1. Am I using it right?2. Is there a possible bug? I tried to work around by forcing Pixi to use a canvas and getting a context to that canvas and clearing it myself with clearRect but that didn't work either. I get the feeling I am having some fundamental misunderstanding... Quote Link to comment Share on other sites More sharing options...
robmyers Posted October 7, 2013 Share Posted October 7, 2013 Perhaps I misunderstood, but it looks like you are clearing after you draw... rather than before you draw. If you clear after, then you are wiping all the drawings before you even render. Suppose you want to draw inside the graphics instance every frame, clearing the previous drawing.Then you would repeatedly call a function like: function draw(){// clear all drawing from graphicsgraphics.clear();// draw some stuffgraphics.beginFill(0x000000);// etc.} Also, make sure graphics has been added as a child of the stage (or similar). Quote Link to comment Share on other sites More sharing options...
mwatt Posted October 7, 2013 Author Share Posted October 7, 2013 Sorry for the confusion rob - yeah I am clearing before I re-draw, or at least, wanting to clear. Your example code does assure me that I am calling clear correctly... I dunno what's wrong. Perhaps I am setting up the renderer wrong. Perhaps I need to refactor my code. I'll do some experimentation and either figure it out of post a more extensive example of what I am doing and plead for help again. I guess I will ask one more question before I close here. Is Graphics intended to be a singleton object perhaps? I am using multiple instances of it (but I am certain I am pairing the clear to the some Graphics instance that does the drawing I wish to erase). Quote Link to comment Share on other sites More sharing options...
xerver Posted October 8, 2013 Share Posted October 8, 2013 Graphics is just like any displayobject in pixi, there can be multiple of them anywhere in the scene graph. Checkout the examples in the repo for an example of using the Graphics object. Quote Link to comment Share on other sites More sharing options...
mwatt Posted October 8, 2013 Author Share Posted October 8, 2013 Just to close the loop on this, there is no Pixi problem. It was my own error. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.