hi,Is there anyway to create a multi paged application in processing...like an application with a next page button where the user can click and move to the next page.Sort of like the hyperlink of web pages..Please help
AFAIK, such GUIs can be made in any programming language! ;))
You just need to set a variable apart to keep track which page is currently active.
And of course, take diff. decisions based on it! :P
@GoToLoop ....i don't quite get it ,this example in the link is about text boxes.I am not a really experienced programmer so i don't see the correlation.....Plus you said i should set a variable which will track active page.In processing , what is the active page ,there is one setup() and one draw().how do i make duplicates of these.Please be patient with me i know it might sound a bit stupid :) ....please could you just show me a snippet which has at least two pages where a user can click to the next...please.
...could you just show me a snippet which has at least two pages where a user can click to the next...
I've got none! b-(
... what is the active page...
There's only 1. Although we can also make off-canvas w/ PGraphics. But you won't need such scheme.
But what makes a "page" diff. from each other is the content you display.
So for each value of "page", you draw a diff. GUI and check for diff. buttons and textboxes! [..]
@GoToLoop@calsin is there a method like clearScreen() to clean every thing from the screen and start the drawings for the next page?.I tried using background inside mousePressed()
for specific coordinates of mouseX and mouseY to sort of create the Next Page button but it doesn't work
Function background() is the common procedure to clear whole canvas! /:)
You just need to render the screen w/ a GUI corresponding to a "page" sorta variable! [-(
static final int MAX = 2, GAP = 50, DIM = 120, RAD = DIM >> 1;
Those are constant fields, representing values that are set once & can't be changed later.
In Java convention, they gotta be fully capitalized!
And if composed by more than 1 word, separated by underlines like this: MAX_INT, TWO_PI, etc.
It's an undocumented Processing function which allows invoking a method as a String name!
It uses a "hackish" thing called reflection. There's also thread("") which does the same;
but asynchronously executes it by instantiating another Thread on-the-fly!
pageSelector(); // For JS!
Since JS Mode doesn't implement neither method("") nor thread(""),
I had to emulate the Java Mode's behavior via switch/case in a separate function: http://processing.org/reference/switch.html
Though method() is still "hidden" from public, its usage is the same as thread()'s, but it's synchronous instead. It doesn't create a separate Thread in order to invoke the method's name specified by the passed String parameter. :-B
Answers
AFAIK, such GUIs can be made in any programming language! ;))
You just need to set a variable apart to keep track which page is currently active.
And of course, take diff. decisions based on it! :P
As for starts, take a look at this post below for something similar to what you want:
http://forum.processing.org/two/discussion/423/how-to-write-a-class-for-text-area-without-using-any-library
And here to test it online:
http://studio.processingtogether.com/sp/pad/export/ro.9Zo$UbIWYZEDR/latest
@GoToLoop ....i don't quite get it ,this example in the link is about text boxes.I am not a really experienced programmer so i don't see the correlation.....Plus you said i should set a variable which will track active page.In processing , what is the active page ,there is one setup() and one draw().how do i make duplicates of these.Please be patient with me i know it might sound a bit stupid :) ....please could you just show me a snippet which has at least two pages where a user can click to the next...please.
I've got none! b-(
There's only 1. Although we can also make off-canvas w/ PGraphics. But you won't need such scheme.
But what makes a "page" diff. from each other is the content you display.
So for each value of "page", you draw a diff. GUI and check for diff. buttons and textboxes! [..]
Some online examples on buttons: :-j
http://studio.processingtogether.com/sp/pad/export/ro.9ABG0RKl9D2Bx/latest
http://studio.processingtogether.com/sp/pad/export/ro.9vAkI4JDuLs8s/latest
@GoToLoop@calsin is there a method like clearScreen() to clean every thing from the screen and start the drawings for the next page?.I tried using background inside mousePressed() for specific coordinates of mouseX and mouseY to sort of create the Next Page button but it doesn't work
Function background() is the common procedure to clear whole canvas! /:)
You just need to render the screen w/ a GUI corresponding to a "page" sorta variable! [-(
@GotoLoop I am sorry, i don't quite get the second sentence. I tried something like this but it does not work
//i expect something like to wipe everything off and draw just a square on "mousePressed()"
void mousePressed() { if(((mouseX>20)&&(mouseX<60)) &&((mouseY>30)&&(mouseY<90))) { background(255); rect(20,20,60,60); }
I've had no choice but implement a model to show ya! :(|)
You can check it online below:
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9eDRvB4LRmLrr
Any doubts about the code, don't fret to ask here! ^:)^
@GoToLoop I finally get it...thanks a lot for your patience ,really thanks :)!
what does this mean?
i dont understand what the case is for: :<
** can you also let me understand how did you make the class?**
sorry im really noob at this.. and im making a maze game for our project... the concept is like The MAZE game in winterrowd.com
I let GoToLoop to explain why he uses >> 1...
Otherwise, it just creates a number of constants, numeric values with explicit (more or less) names.
case: see the Reference page on the switch statement.
Hello @hanakimchi! Here comes the 1st part: :D
static final int MAX = 2, GAP = 50, DIM = 120, RAD = DIM >> 1;
Those are constant fields, representing values that are set once & can't be changed later.
In Java convention, they gotta be fully capitalized!
And if composed by more than 1 word, separated by underlines like this: MAX_INT, TWO_PI, etc.
The
>> 1
is the same as an integer/ 2
: http://processing.org/reference/rightshift.htmlHighest performance & gr8 at enforcing an integer division in JS Mode!
method("page" + page); // Java only!
It's an undocumented Processing function which allows invoking a method as a String name!
It uses a "hackish" thing called reflection. There's also thread("") which does the same;
but asynchronously executes it by instantiating another Thread on-the-fly!
pageSelector(); // For JS!
Since JS Mode doesn't implement neither method("") nor thread(""),
I had to emulate the Java Mode's behavior via
switch/case
in a separate function:http://processing.org/reference/switch.html
Actually, JS can emulate method("") via its "hackish" eval(""), call(), etc. functions:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call
However I decided not to in order to keep it more in line w/ Java Mode!
You gotta be more specific in which part within Button class you don't understand well! 8-X
For GoToLoop
Can you talk more about method( ); ? I'm not sure to have understood and I can't find anything on the subject...
Hey @GameParticles! In P3, they've finally decided to turn thread() an official API:
https://Processing.org/reference/thread_.html
Though method() is still "hidden" from public, its usage is the same as thread()'s, but it's synchronous instead. It doesn't create a separate Thread in order to invoke the method's name specified by the passed String parameter. :-B