Help understanding Scroller.Y

Get help using Construct 2

Post » Wed Nov 28, 2012 3:53 pm

Hi, as per the topic, I'm having problems understanding this command (and if I'm hitting a wall with this kind of simple command, I'm doomed). I'm messing around Scirra's Space Blaster template, and noticed the ship is "locked", unable to move beyond an area. In the code, this reads as:

[code]>Prevent the player flying ahead too far or going off the bottom of the screen.

Player : Y > Scroller.Y + 300
        Player : Set Y to Scroller.Y + 300

Player : Y < Scroller.Y
        Player : Set Y to Scroller.Y[/code]

My understanding is that the 300 value is basically the area that "locks" the ship, preventing it from going further (any value above increases the area vertically, trapping the ship if moving down; any value below it narrows the area). While I'd like to know how I can make a ship be able to reach the top of the layout screen (but now go further than that), I'd also very much like to understand the the uses of Scroller.Y.

I've also searched the forums and haven't found a concrete answer, though maybe it has to do with my search terms
B
8
Posts: 24
Reputation: 638

Post » Wed Nov 28, 2012 4:17 pm

Scroller.y is probably just a point of reference to get a .y coordinate, a sprite that is invisible, its not really a system function

by deleting these events you should be freely reach the top, to go further the "window size" should be increased, and there should be an event or a behavior "scrollto" on the ship so that the screen follows the ship object

hope this helps a bit
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Nov 28, 2012 4:24 pm

Thanks, I'll give it a quick try :) Also, my bad, I meant to say "make a ship be able to reach the top of the layout screen (but not go further than that)", instead of "now", meaning it should fly freely around the screen but never cross/go outside the layout.
B
8
Posts: 24
Reputation: 638

Post » Wed Nov 28, 2012 4:38 pm

you can just position the ship at the the top, where you want it to stop,
check the y position, and then make an event, ship.y < 50 set ship.y to 50

as the ship y position gets lower then 50 (at the top) it will hold on 50
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Nov 28, 2012 4:54 pm

'Scroller' is just a sprite object moving slowly up the layout. Try making it visible so you can see what it does.

Y co-ordinates increase downwards, so if the Y co-ordinate is greater than something it means it's below, and less means it's above.

I think the latest version of the template uses the viewport expressions, which means it supports any window size. For example, to allow the player to move anywhere on-screen but not go off the top or bottom of the screen, use the following (but update to use the appropriate layer name):

Player: Y < ViewportTop("MyLayer")
- set player Y to ViewportTop("MyLayer")

Player: Y > ViewportBottom("MyLayer")
- set player Y to ViewportBottom("MyLayer")
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Wed Nov 28, 2012 9:03 pm

My thanks, Ashley. I did check out the Scroller, making it visible and changing values as well. I got a somewhat better idea of what to do with it now :)

On the other hand, I'm almost ashamed to say how bad this is going on otherwise, though I'm the only one to blame really. I have followed your suggestion, and also went probing everywhere I could think of. Maybe I'm not giving the proper instructions, or maybe it's due to me using the free edition, can't tell.

I'll poke this a bit harder for now then call it a day.

B
8
Posts: 24
Reputation: 638

Post » Wed Nov 28, 2012 11:04 pm

So. This is what I did:

[code]Player : Y > Scroller.Y + 280
       Player: Set Y to Scroller.Y + 280

Player : Y < Blocker.Y
       Player : Set Y to Blocker.Y[/code]

Aaaand... It works. This is interesting, because I've always been terrible at game editors, but I got this to work. Blocker, by the way, is simply an invisible sprite with the same shape and size of Scroller, along with its Bullet behavior and speed, placed a bit above Scroller.

So I can sleep a bit easier tonight! My thanks to both of you once again :)

Edit: I changed 300 to 280 because after changing the Y < Scroller.Y, the ship began going further down. 270 might be more adequate, though.bergmark2012-11-28 23:06:15
B
8
Posts: 24
Reputation: 638


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, Kagubro, Solomon and 28 guests