juliogomez7 Posted August 4, 2017 Share Posted August 4, 2017 I'm just starting to learn PandaJS and I need to make a drawing game, where the top section has some controls to choose the type of figure, color, etc, and the bottom section is the drawing area (I attached a quick mockup) I've implemented some interaction with Pixi Graphics to draw the figures but in this moment everything is mixed into a single section, and the drawing starts just where I click the button to choose a figure. I want to be able to click any control from the top section and then start drawing when I click the bottom section. I've tried with containers but I don't really understand them. Which is the best approach for this? I'm currently using Panda 1.13. I will provide code if necessary. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 5, 2017 Share Posted August 5, 2017 Hi @juliogomez7 The way I would do it, is to make the drawing buttons like you said, and a canvas ( you can make this a white sprite to draw on ). Here is an example ... If 'pencil' button is selected and mouse is down, check if the mouse is touching the canvas sprite and only then enable the drawing Hope this helps a little bit. Quote Link to comment Share on other sites More sharing options...
juliogomez7 Posted August 9, 2017 Author Share Posted August 9, 2017 Hi @Ninjadoodle, that approach worked, thanks! Now I have sort of a more complex problem, I need to draw shapes like squares or circles in a way that the user sees what he is drawing. I'm doing this by clearing and drawing again the shape every time the mouse moves to a different point (I don't do this with the pencil mode), but I haven't be able to draw another shape without clearing the one that's already drawn. Also I need to keep track of the shapes I draw, because there are going to be undo and redo options. Should I create a new Graphics object for each shape or what else can I do? Here is a gist so you can see how I coded the drawing: https://gist.github.com/JulianBonilla7/39ab2e403cbd43f55617998f25e3d136 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted August 10, 2017 Share Posted August 10, 2017 Hi @juliogomez7 I haven't really played with the drawing api at all, so sadly I'm not the best person to help with this I wonder whether there is someone else here who made something similar with Panda, that could help. 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.