Help understanding Scroller.Y

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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:

    >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

    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 <img src="smileys/smiley26.gif" border="0" align="middle" />

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • '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")
  • 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.

  • So. This is what I did:

    Player : Y > Scroller.Y + 280
           Player: Set Y to Scroller.Y + 280
    
    Player : Y < Blocker.Y
           Player : Set Y to Blocker.Y

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)