We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello guys,
I need help again, I will try to explain ...
I'm adapting some sketches (obtained in OpenProcessing, where I am adjusting to a project at the company where I work ...), two of them are in these links:
http://www.openprocessing.org/sketch/31621 http://www.openprocessing.org/sketch/175059
In this case, when I run individualistically, has a paint effect that seems to be "swiping" ... OK, this is how we like to run it.
My problem occurs when I add in the project along with other scketchs, so that work in sequence (options, it would be more appropriate to say ...)
When I run within the project, has a different effect, is "cut through" the design, changing the way ...
My question then is, has anyone ever seen this effect (just changing a command to switch the route?)
I decided not to put the code, at least for now, to be a bit long (with the multiple sketches), just put the prints, to have an idea of what's going on, if need be, later put here.
Thank you for your attention now.
Thank you,
José Aparecido
Answers
here I demonstrate how to join different sketches.
You need one setup() and draw()
these can call
setup0(), draw0() (the former old sketch 1)
setup1(), draw1() (the former old sketch 2)
etc.
did you mean that?
here comes a version with images.
the images must be in the sketch folder.
they must be called 0.jpg, 1.jpg, 2.jpg (exactly like that)
;-)
Hi Chrisir,
I managed to control options as you said last time, I'm able to develop the project based on this principle, program1, program2, etc., works very well ...
The problem I'm having is that has an "unexpected effect" when run within the project with various sketches, because when I run individually have another result, as shown in the pictures.
The problem is that as I have several sketches, it would be a little tricky to know when can be being changed some setting that causes this change effect, so I asked if anyone knows how to provoke this purpose effect, so I can see where you are going to change to occur it.
I will leave here of the code code, to have an idea what I'm trying to explain ... as I said before, excuse the failure to communicate in English ... rsss ...
... Print how the programs are divided, and the menu running, with various options (works great).
Part of the project code (will not compile, because it contains everything you need here ...)
if I understand you correctly you encounter side effects that you do not want.
The (former separate) sketches (inside the mother sketch) influence each other what you don't want
TfGuy44 made a great frame sketch for that issue.
here each class can be seen as a program on its own.
http://forum.processing.org/two/discussion/11573/a-new-class-state-how-to-tackle-bigger-programs
quote:
the approach is a little complex but :
each state has its own class
the state classes have each only one object (one state)
the states are stored in an ArrayList with the index "currentState" (which changes)
each state can have all the vars it needs within the class. So you minimize the global vars and the bad side effects
there are other classes like buttons outside the states. These other classes are not part of the approach really
Hello,
The problem is the same (undesired side effect), when I run multiple sketches together, though each has the "setup" individual, it should be something in memory, I'm not knowing how to control ...
I'll take a look at this other model, for how can adapt the project.
Once again thank you ...
Hello guys,
Continuing to research how to operate multiple sktches in a single project, I found this solution, which was adapted this link:
forum.processing.org/two/discussion/10937/multiple-sketches
The way I'm developing works well, but sometimes have some "side effects" when you run certain animations ...
This otherwise found interesting, because each is actually separate.
I need help on a detail, for example:
When I perform a sketch, and opens a second frame (window) when you close the last open, closes the entire application.
In exemploA, I'm trying to control it using controls on the ESC key.
Someone would know if you have any other way to close only aa second open window, and let main (Menu) running?
Another thing, I could create run-time window? I tried this, but did not, gives the message that the object needs to be started.
Yet another detail, how do we "destroy" the window created after closing? I tried to use the destroy () method, but does not seem to work because when I call the window again, does not start setup () (called the window), but draw () is executed, but without the settings that are in setup ()
I hope you can understand ...
For now that's it, thank you from the attention,
Thank you,
Notes: Do not put the programs as images, are just examples, to ride the way will work.
Código adaptado do exemplo:
Hello guys,
Still with the matter of using multiple sketches, I am trying to adapt this other model, but still has a detail that I'm unable to solve, I will try to explain.
When I call a particular option for a second time does not run the setup () function.
That is, the first works normal, if another access option and return the previous, the setup () function is not loaded, and it affects the performance in draw ();
I've tried to create another function on Extended Applet (setupBall eg using public static void ...) but can not access, the Skecth where the menu.
Any idea how to fix this?
Below the print screens as is getting the project, and a snippet (not put all because it is getting a little long).
size in a class is not allowed
line 147
size() should be used only once in your sketch (in line 30)
general I would recommend to work with states.
meaning:
use int currentState = 0;
in btn01, btn02 etc. you want to set currentState to 0,1 etc. and you want to call the setup of each class
in draw() you say:
(set
currentState=1000;
in setup())compare to TFGuy44 first answer in http://forum.processing.org/two/discussion/11573/a-new-class-state-how-to-tackle-bigger-programs )
In order to avoid an all-green posted code in this forum, always use
/**
instead of/*
! :-\"Hello Chrisir,
Thanks for the tips, I'll check best how to solve this ...
I could "destroy" the applet, and recreating every time you call?
instead of doing it at the beginning:
I would like to do so:
static final PApplet ExemploA, ExemploB, ExemploC;
And then create when actually call each option.
What about the code, mentioned by GoToLoop, I understand, to again place as directed.
Many thanks again ...
More detail
Before attempting this solution was commenting, I would also like to try to understand a detail when instantiates several sketches.
I tried to "destroy" the instance, but it seems not work as I expected because it still created.
Call to "destroy"
Function used, as in the previous example Forum:
no...
don't use the destroy thing
you can also use the normal way to instantiate the objects
my point was to use setup() so you can make a clean stage at the starting of each state / object and also have a clean clear
draw()
as I've shownBefore changing as suggested, I would try something else (I'm really stubborn ... rsss)
The problem does not appear in Call of ControlP5 Library button, I used them, just to let the simplest example, but other means of work, with the Button class that was passed in the first model, it works perfectly well ...
We made some adaptations and then I will continue using this library to create buttons, because it facilitates to create various menus.
Button class code before passing (adapted some details) ...
//Structure mount Menu:
//Buttons function call
Anyway, I put more code to get an idea, how to create the menu can be optional, the biggest problem is to separate the Scketchs, I will keep trying this model, it does not work, try the other that was suggested.
If you can give some hint has "really like to destroy" the instance created applet (sketch) and always create again when called, would be helpful.
Thank you again.
sorry I haven't really done this ControlP5 plus multiple sketches thing
but anyway sure you can destroy your instance
Sorry ...
I did not understand what to say had tried to work with states ...
No way I really wanted to speak English at these times (thankfully google translator helps me) ... I will analyze better, then I put the results here.
Thanks.
you're welcome.
@Jose_Aparecido, dunno enough of Processing's innards as to properly destroy() a PApplet, sorry!
However, dunno why frame.hide() & noLoop() wouldn't be enough for ya either! (:|
Hello guys,
So frame.hide () & noLoop () solves the problem to some extent, because I can see at the right time as choose the option.
The problem is when I come running when I go out, have some "effects" collateral, and does not work as the first time you called.
Below is an print from one of the options when you run the first time, and the second (appears some arrows, I do not know where you are doing it), if I run a third time back to normal, like the first time you ran, and so on ...
So I figured if created at the time of the call, and then destroy, thus solve the problem.
//Run the first time
//Run the second time
Got a way to call the setup complement () ... (but made even gambiarra ... rsss ...), but it seems that the problem is not to have called setup (), but something else, which still I do not know what can be, though each sketch is in separate instances.
I'll keep trying here ...
Thank you,
att,
this seems to be a feature within the initial sketch
post the source here pls (url to openprocessing or code)
try finding the lines
try to set the boolean var off in constr of that state
Obrigado novamente,
ops was wrong, I took part in Portuguese, sorry ...
I will do without the ControlP5, to see has the difference ... then post here ...
Thank you again,
This is the code I adapted, with sample forum with multipos sketches, and the animation OpenProcessing.
//Program Menu
//Program Animation
Thank you for equanto again tomorrow still here ...
Sorry, I forgot to schedule correctly, turned green, where it should not ...
As I already tipped ya: "Replace every
/*
w//**
!Please, check your Portuguese to English auto-translations!
Even better, post both languages so we can have a better chance to figure it out harder parts!
I'm sorry again, it was an error even when it comes to copy and paste ... I'll be more careful.
Thanks,
Remember that we can always "Edit" our posts! ;;)
OK,
Have a nice day!
Hello again,
The code that I put before will not work, was missing parts ... I'm putting another with two options working, thus giving to get a better idea of what is happening ...
Recalling, in "Balls" animation, when you enter the first time, is OK, the second time running, arrows appear in the animation ... is executed again, it is OK ...
As for the "Paint", when you run the second time, change the background color, so I realized the second time does not run the setup () function frame created (Extended), when he called again, just draw () function is performed, of course, because setup () only runs when the sketch is created ...
Need to see a way around it, I tried to do something in exemploA, but still not ideal.
If they can analyze the code and give some hint of what might be happening, it would be helpful.
Once again thank you all ...
Project code (You need to create source in the Local Machine)
Observations: I'll separate programs due exceeds the limit for posting
Hello again,
Sorry, this simple mistake of the arrows effect, happened after I put the ESC key to close the screen because using X, closes the entire application ...
Sorry again ...
I still can not solve the problem, the running the setup () again, after the start of aa first time the application if they can suggest something, it would be of great help.
Thank you.
Oh yes the code which was causing the effect ...
void keyPressed() { if (key == ESC ){ key = 0; configurar = true; disableSketch(ExemploA); //destroySketch(ExemploA); } -->//showVectors = !showVectors; }
what do you need to be solved?
what is the problem?
I don't have time to look into it
you could post the code here https://gist.github.com/
or provide an mcve - http://stackoverflow.com/help/mcve - but your problem is probably not reducable to an mcve
Hello Chrisir,
The problem still seems to have some "side effects", when you enter a second time on the screen ... as screen background with other color, for example ...
I figured it would restart some variables that are normally initiated in setup (), so the call again.
But got a way around this, although it still has some unexpected effect.
I still can not solve another problem ... which is when closing a second window with (x), closes the entire application.
I tried to control it with the ESC key, but time works, and time does not.
Any idea how to fix this? That is, how close the window with (X), and not close any application?
Thanks again for your attention.
One more detail,
The ESC also (like when you close with X) closes the application in any window that is open, without this control that tried to put (key = 0) when you press the key.
This is a drawback, because need return to the Menu screen, so I am a means of controlling it.
Thanks,
ask gotoloop ...
Hello Chrisir, Gotoloop ...
I think it would be really interesting to find a solution to this problem, I think this is a very good way to work with multiple sketches, so each gets their separate controls, facilitating the development.
The other way as you explained, also works well, the problem is that sometimes arise some "side effects", which is more difficult to control, as it adds programs to the Project.
As I mentioned before, this project aims to beneficar people with mobility difficulties, so some features "ordinary" as the "Paint" and "MediaPlayer" ... because an application in Processing for example, we can add other features beyond Keyboard and Mouse, as the Kinect, Leap Motion (and others with the Arduino) ... anyway, thus ways for people with a disability, can do some type of interaction with a computer.
I am grateful for the help I have received so far without your help, it would be very difficult to move forward ...
What about you Gotoloop, any suggestions on how to solve it?
In other words, noting that the problem is that when closing the window (at X) and is the second open window closes entire project.
If I put the control in time key works not time (sometimes need to press the mouse ja window to function, sometimes closes all to no (X) ...
There would be some way to define a sketch as "Main", where the menu, is when closing a second open window, close it alone, and return to the Menu?
Thanks again for your attention.
Sorry but I also wish I knew how to control window buttons' behavior!
Perhaps if we could hide window's buttons but dunno how either!
I've got a vague idea of some forum thread about button hiding, but am not so sure!
In short, that's Java's advanced JFrame stuff. It's beyond me! X_X
Hello GoToLoop,
Thanks for the feedback, do not apologize for that, I do I have to apologize for being "disturbing" so so ... but I believe that solving it will help me a lot in the project I'm developing, and believe it can be used by others , which are likely to go through the same problem ...
I'll keep trying a means to better get around this, and having something new, I put here ...
Thank you very much for now again ...