We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I was just developing a program and I needed a function that can do something like what camera() does but in 2D. I wanted to use camera, but it kept erroring me that the function is not working with the renderer, so I went to Processing's reference and so it was. Another way to do this is to change the renderer to P3D and put like a 0 as the third argument at every single I have drawn, but this seems like the hard way, and I'm not even pretty sure that works. So any sugesstions?
Answers
Perhaps you should look at its implementation and adapt it to work for 2D! *-:)
https://github.com/processing/processing/blob/master/core/src/processing/opengl/PGraphicsOpenGL.java#L4421
Although I dunno if that would make any sense! :-S
it depends a little what you want to achieve
there is a huge thread with a map for a game (zelda or so)
the map for the game level is much bigger than the screen. But only the part where the player is is shown on the screen. If you like the camera moves over the map. It's called viewport.
http://www.openprocessing.org/sketch/149191
Chrisir ;-)
@GoToLoop I don't really know what to do with that huge library you gave me. I tried to understand it but it just doesn't seem what I am looking for.
@Chrisir Thank you for the example you gave me, but again, it is too complicated for what I want, but I could extract the part I'm interested in abd go with it. I will keep you in touch with the progress.
Flu ;)
yeah, I just wanted to give you an example...
my question is, what exactly do you want to achieve?
Is it a map like this?
you can make a class Viewport and store the stuff there (camera x,y)
then depending on them, draw your stuff differently
Nope, far more easy than that. I just think the answer is close but I can't figure it out. When the mouse wheel is rotated, a scroll effect should happen and scroll all the sketch down, where other stuff is happening. Nothing more different than what happens when you scroll a webpage. You understand, now? I just don't wanna mess up the other coordinates that are already there.
maybe you can just use
?
;-)
I don't quite know what you mean by mouseWheelCurrent, but anyway, I found a way to do this. I could set a float mouseWheelCurrent (like you said) and make an while loop. While the mouseWheel returns 1.0, the float rises. When it returns null (i'm not sure if it returns null or zero) the float stagnes. When it returns -1.0, the float decreases. And I can use that float with the translate function (also your ideea). Seems like a good idea to me ~O)
MouseEvent's getCount() method returns an
int
:https://github.com/processing/processing/blob/master/core/src/processing/event/MouseEvent.java#L112
Although P5's reference thinks otherwise in its example:
http://processing.org/reference/mouseWheel_.html
If you try to print it it says either 1.0 or -1.0. That's a float, so...kind of confusing...
if you take some numerical value and assign it to a
float
ordouble
,of course it would become a floating-point value! 3:-O
hi, I just didn't want to make it too easy for you...
So I just gave you the rough direction
;-)