Touch to scroll layout

Get help using Construct 2

Post » Wed May 09, 2012 5:54 pm

Dear all,
I'm working on a game using a layout larger than the playing window. I'd like to be able to scroll the layout left/right with a finger through a touch command.
Programming logic a a little beyond my comprehension so I'd need your help for that.
Kind regards
Laurent
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Wed May 09, 2012 6:35 pm

I suppose you want to scroll with a swipe...
This is a bit tricky, I may be able to put up a capx when I get home.

B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed May 09, 2012 6:44 pm

That's it !
Thanks for your help. It will be much appreciated.
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Wed May 09, 2012 7:09 pm

If you want to do this for a fullscreen-able game, use scale mode for project and create a invisible object with the "scroll to" behaviour and with the size or your default window size ... the goal is to make this object move and auto scroll the window automatically for you on every tick. For example, if this object "scroll" is centered with X=320 Y:200 (640/400 window size)

On every tick
If Is in touch          -> scroll.X=(Touch.X+320)/2
If not in touch        -> scroll.X=320

The last condition is here to centered the view again when you touch nothing

naelian2012-05-09 19:35:27
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Wed May 09, 2012 7:23 pm

If I'm guessing right, is this like the scrolling/swiping thing you see in an Ipad? Or is it just a scrolling thing you'll see in a browser? Cause in a browser, when you release the mouse button/mouse scroll, the scrolling stops, but in an Ipad, when you release your finger after swiping it in the screen, the screen still moves until it reaches the other page.
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Wed May 09, 2012 7:37 pm

Yes it's true, need more details for good answer ;-p
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Wed May 09, 2012 8:17 pm

Well, both would be nice. The first one to navigate on a huge layout, the second as a transition to another layout.
Naelin, thanks for your solution. I thought about it but there's a problem : the big invisible square intercepts the touch command applied to active objects on the layout.
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Wed May 09, 2012 10:25 pm

Hmm, you can probably try scaling down that big invisible square and put it maybe on the lower right cornoer or somehting and just have your finger swipe on that certain part of the screen just to check if it would work. If it does, then your next problem is your post above.
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Thu May 10, 2012 6:53 am

Big square "scroll" is done with what kind of object ? ... never use a text object as "scroll" !! ... text objects have strange behaviour making them displayed always on top of all others objects ... so perhaps even intercepting the touch event ! ...

I use a centered invisible empty "Sprite" object as "scroll". To be really sure put this "scroll" sprite object on the bottom of the most bottom layer of the project behind all "active" objects ...
naelian2012-05-10 07:12:58
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Thu May 10, 2012 8:11 am

Thanks for this suggestion but I really would love to avoid using this transparents objet. Because, as specified, it intercepts actions on active objects that it overlaps.
Would it be possible to use another approach with, for exemple, recording the absolute position of a click/touch spot on the screen and transmiting its movement to the layout ?
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Next

Return to How do I....?

Who is online

Users browsing this forum: selaus and 0 guests