Out of Bounds

0 favourites
  • 14 posts
  • Specs: Windows 7 + Firefox + r79.4

    Example: OutofBounds.capx

    Updated:

    How do I make sure the spaceship will never leave the viewport when my mouse position is outside the game? ;'(

    The ship image appears in the viewport, but the position is outside of it so the enemies won't collide and destroy it.

    &Solved! (Removed the .capx file)

  • Edit the animation of the rocket ship and push the bounding polygon out a bit, maybe a box on one side.

  • I don't have any animation on the rocket ship and it's bound by layout.

    I'm a bit frustrated that the enemy sprite clearly overlaps the ship, but it does not collide & destroy it just because it's in a secret safety corner. This heavily affects the gameplay because anyone can do this to cheat and add to the score.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your problem seems to be related to the mouse control you implemented. If you "debug" your code, by having the X and Y position of your spaceship displayed every tick, you will realize, that the "missed" collision only occurs when the actual ship position is outside the viewport. Since you have restricted the ship to stay "inbound" you are unable to tell this by just looking at the animation.

  • I thought that by making the ship bound by layout, the ship wouldn't escape when the mouse is outside of the layout.

    Am I supposed to bound the mouse position to the layout as well? I don't really know how to do that. How do I make sure that the spaceship will never leave the viewport? ;'(

  • <img src="http://dl.dropbox.com/u/36472942/construct/forumhelp/Check_Mouse_Coords.JPG" border="0" />

    Simply check the mouse coordinates. If they are out of bounds, don't move the sprite.

    Also beware, your ship has 9 collision points which is not recommended (8 max).

  • Kyatric's method seems less intimidating than Yann's method, but both methods work! :D

    I shall go look into what "clamp" is and where "self" is from.

    Thanks for the help guys! Much appreciated!

  • clamp just limit values between a minimum and a maximum

    self refers to the object from which you do the action.

    awesomeSprite: Set X to self.myVar

    is the same as

    awesomeSprite: Set X to awesomeSprite.myVar

  • So I'm trying to figure out what your expression means:

    X Position: You limited the object's horizontal movement or position on the x-axis to a minimum of half of the object's width and a maximum of the layout's width subtracting half of the object's width.

    Min: Half of object's width = 38

    Max: Layout's width (640) - 38 = 602

    The object's movement is limited to a minimum of 38 and a maximum of 602 on the x-axis?

    Sorry if I don't really understand. ;X

  • 'cause the image point is at the center of the sprite. If I don't offset things by half the width and half the height you will have half the sprite out of layout. But maybe it's not a problem for you (:

  • Ooh, the image point is taken into consideration in the expression as well.

    So if it was on a grid, the object can only move between those two values?

    (I'm a super noob, so I need the dumbed-down explanation. *blushes*)

  • Since the origin of your image (its x and y coordinates) is centered, if you add or remove half of its width to its x coordinate you get the coordinate of the left/right border of the object.

    This way, staying in the range (38, 602), you are sure that your image sticks to the boundaries of the screen horizontaly.

    Same logic verticaly.

  • ;O I think I get it! Thanks for the explanations!

    Sorry if it seems like I'm harrassing the forum with my noob questions. Hehe.

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