Mouse / player to bound to an given area

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I was wonder so im making a bullet hell type shooter. And I was wondering how can i bound the ship to an area where my UI is and not have the player to go off the game.

    I know what bound to layout but this is within the given area. Is there some fancy footwork i can do this easily or do i have to create invisible solid sprite ?

    Just a quick edit here I am using movement of mouse using everytick to mouse position is there something similar i can use so that the UI can be solids to do this with ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For Keyboard movement - yes, just make a solid transparent sprite.

    For Mouse movement - even with solid sprites, it will not work. But there is a way to make it.

    Just edit your ship/player sprite. Click "resize", and now add to the width and height, pixel values of your "walls/UI", Then change "Image" to "align center" so your ship will not be stretched, check "apply to whole animation" and your almost done. Now you have bigger image, but your ship is same size as before, so just "set collision polygon" just for the ship and thats it. That empty space in your sprite will now be working like extra walls, so your ship cant leave that your speciffic area.

    If every wall you have has diffrent width/height then just add value of each wall as blank/transparent pixels to your player sprite in photoshop or other program like this.

    If you want see how it works, then look at my brickout/arkanoid clone:

    https://www.scirra.com/arcade/action-ga ... brick-7787

    As you can see there, you move with mouse easly but you cant break thru the laser walls. (these are just simple sprites, not solid)

    And here you can see how looks my ship/player sprite. As you can see I have some empty space on both sides of this sprite. This empty space is just as big as my walls, so with behavior "bound to layout" these empty space works like invisible solid walls <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    PS. Sorry for my english <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz"> I hope you get the point <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • [quote:1fmuwsza]clamp(x, lower, upper)

    Return lower if x is less than lower, upper if x is greater than upper, else return x.

    sprite set x clamp(mousex,100,700) and same for sprite.y , makes it easy to contain a mouse controlled sprite movement .

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