I'm trying to get a vertical scrolling room working.
Gameresolution: 640x480, room background resolution: 640x5421
Can't figure out why this piece of code doesn't work...:
function room_RepExec()
{
if (mouse.y <= 20) { //if mouse is near top of screen
SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels. Change this for quicker or slower scrolling.
}
else if (mouse.y >= 300) { //if mouse is bottom of screen
SetViewport (GetViewportY() + 10, GetViewportX()); // scroll up 10 pixels. Change this for quicker or slower scrolling.
}
}
You're ADDING ten pixels in both cases. Obviously the first case should subtract them. Also you will need to check that you're not setting the Viewport out of the room bounds.
Edit: Did you just edit the code? Or am I seeing things? Just realized, you've inverted the x,y coordinate order in SetViewport.
added this:
SetViewport (GetViewportY() + 10, GetViewportX()); // scroll down 10 pixels.
into:
SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels.
I noticed it after submitting the post...
The problem is that it doesn't scroll at all ???
Made an edit of my own:
Quoteyou've inverted the x,y coordinate order in SetViewport
{
if (mouse.y <= 20) { //if mouse is near top of screen
SetViewport (GetViewportX() - 10, GetViewportY()); // scroll down 10 pixels.
}
else if (mouse.y >= 300) { //if mouse is bottom of screen
SetViewport (GetViewportX() + 10, GetViewportY()); // scroll up 10 pixels.
}
}
Having this, still nothing happens.
Dude, you still need to add/subtract the pixels from the y coordinate (vertical), not the x (horizontal)
I'm sorry but I don't understand it.
Tried this
SetViewport (GetViewportX() - 10, GetViewportY()); // scroll down 10 pixels.
and this
SetViewport (GetViewportY() - 10, GetViewportX()); // scroll down 10 pixels.
both do nothing...
SetViewport (GetViewportX(), GetViewportY()-10);
That's scroll UP 10 pixels, btw.
OK, got it. Thanx!
Wow. ;D
Yeh sorry, I know... ;)
Somehow I thought I needed to switch GetViewportX() & GetViewportY()
in stead switching the number of pixels from X to Y...
Anyway...
;D
Sorry, but that's the funniest beginner's tech thread I've seen in a long long time.