Okay, so Im making a game creator game http://scratch.mit.edu/projects/TheScratchTest/2713675
And I've got most of it down, but im wondering about scrolling. I want it to scroll both ways when you're playing as a character, and I also want it to scroll by a scroll bar when you're editing the level. Scrolling is actually very complicated. With all the velocity and stuff. So if you could please explain it as if you were explaining it to a 5 year old for me I would appreciate it. Please, do not post any engines.
when gf clicked repeat until <helped> HELP ME!!!!!] end
Offline
The wiki scrolling article can probably explain it better than I can. For the scroll bar, you essentially make the scrollX variable a function of the x position of the scroll bar. I'm not sure if yours is positive or negative, but is should look something like this:
set [scrollX v] to (((x position)+(240))*(scale))
Offline
You could have a scroll bar, or use the mouse to scroll (by holding down and dragging). This might be useful if you can scroll x and y too. For x and y scrolling, you could just use Pythagorus' theorem and/or trig.
This would give an effect like on iPods where the user can 'drag to scroll'.
1) Work out the position that the user clicks first.
2) Find the x and y components of their mouse movement. This can be done by taking the current position of the mouse away from the original.
3) FInally, scale up/down to however sensitive you want the movements to be.
The final script would look something like this:
when gf clicked forever if <<(editing) = (true)> and <mouse down?>> set [xpos v] to (mouse x) set [ypos v] to (mouse y) set [memoryX v] to (ScrollX) set [memoryY v] to (ScrollY) repeat until < not <mouse down?>> set [dx v] to ((xpos) - (mouse x)) set [dy v] to ((ypos) - (mouse y)) set [scrollX v] to ((memoryX) + ((dx) * (scale))) set [scrollY v] to ((memoryY) + ((dy) * (scale))) end
Last edited by Prestige (2012-08-04 17:59:57)
Offline