keyboard scrolling

New releases and general discussions.

Post » Mon Feb 16, 2009 6:07 am

heya. i recently was sorta making an attempt to make a game but I've already hit a roadblock (lol)

I've got mouse scrolling working with tutorials found in the forum, but I can't seem to be able to get the keyboard scrolling to work - like in RTS where you can press arrow keys to move your screen around.

I've currently set 'the key - is down' and it is instructed to perform 'system: scroll to x 10', but instead of scrolling incrementally, it just warps to x10 coordinates. how can I set the math to work incrementally?



also, another question if you don't mind. is it possible to attach RTS behavior sprites to other sprites so their movements are constricted? like a road, for example. (instead of going through pesky pathfinding.)


thanks!
B
2
G
4
Posts: 17
Reputation: 1,084

Post » Mon Feb 16, 2009 6:15 am

You need to retrieve the current scroll value. So instead of scroll to X 10, it should be scroll to X ScrollX + 10. ScrollX will retrieve the current X scroll value; likewise, ScrollY will retrieve the current Y scroll value.

Also, I don't there's a way to do anything like the second question you asked(not in the behavior, anyways). You'd have to come up with your own method of doing that.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Mon Feb 16, 2009 6:28 am

woot! thanks. that solved my scrolling problem. I'll try to think of something for my second question... perhaps i am to wait for path implementation.
B
2
G
4
Posts: 17
Reputation: 1,084

Post » Mon Feb 16, 2009 8:04 am

Use Time Delta for smooth scrolling!

+Key Right is down
> Scroll.X=Scroll.X+20*TimeDelta (use a higher multiplier for faster scrolling)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Feb 20, 2009 11:21 am

[quote="Mipey":3tcler8d]Use Time Delta for smooth scrolling!

+Key Right is down
> Scroll.X=Scroll.X+20*TimeDelta (use a higher multiplier for faster scrolling)[/quote:3tcler8d]

awesome, thanks! :D
B
2
G
4
Posts: 17
Reputation: 1,084


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 3 guests