How do I 'Wrap' in an area within layout window...

0 favourites
  • 4 posts
  • Asteroids is the game. The layout is 1280, 720. The window is 960, 540. Due to having the controls on the left/right sides of the window, i need the sprites to wrap in a 704, 540 size area within the layout window so they do not get obscured by the controls.

    I've been banging my head to figure this out but all i'm getting is headaches.

    Any help would be greatly appreciated and welcomed. And my sore head will be thankful, also.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • IIRC the Wrap behavior can only do layout or viewport and nothing else, soooo... might be that the only workaround is to simulate it through events. Just do something like "If object X position > 704 --> Set object X position to 0" and then adjust the exact positioning so it looks smooth.

    Having the Wrap behavior bound to viewport should take care of the Y coordinates for you, although you can technically do the exact same thing for Y.

  • Talk about throwing a monkey wrench...

    So how to wrap the sprites so the controls do not cover them?

    Is it possible to have a invisible sprite - 704, 540 and when the sprites are not touching that sprite to wrap?

    Dang, gonna have to work on this.

  • I mean I suppose you could have sprites on either side of the screen, behind the controls, which are used to test the X position of objects.

    Basically, let's say your window is 960 x 540, so you can give your objects Wrap behavior and set it to "viewport". Now they will wrap around the 960 x 540 area instead of the entire layout. Now we add the controls that cover up the left and right sides, so our window is 704 x 540. Let's say it's dead center, so we add two objects, Right Boundary and Left Boundary on either side where the controls are.

    Now set conditions like this,

    If object's X position is < X position of Right Boundary --> Set object's X position to X of Left Boundary

    If object's X position is > X position of Left Boundary --> Set object's X position to X of Right Boundary

    This means that when object crosses the Right Boundary, it will get teleported to the Left Boundary and vice versa. Basically it just does what the Wrap behavior does, but with custom borders.

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