Out of Bounds

Get help using Construct 2

Post » Mon Feb 27, 2012 1:10 am

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)Tokki2012-02-28 23:50:50
B
13
S
4
G
6
Posts: 16
Reputation: 3,527

Post » Mon Feb 27, 2012 1:14 am

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

B
11
S
3
G
2
Posts: 110
Reputation: 2,410

Post » Mon Feb 27, 2012 5:35 am

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.Tokki2012-02-27 06:15:26
B
13
S
4
G
6
Posts: 16
Reputation: 3,527

Post » Mon Feb 27, 2012 11:26 am

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.Weishaupt2012-02-27 11:37:02
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Tue Feb 28, 2012 12:56 am

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? ;'(Tokki2012-02-28 01:18:52
B
13
S
4
G
6
Posts: 16
Reputation: 3,527

Post » Tue Feb 28, 2012 1:30 pm


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).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Feb 28, 2012 1:40 pm

Last edited by Yann on Sun Sep 14, 2014 9:31 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 28, 2012 11:35 pm

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!Tokki2012-02-28 23:42:13
B
13
S
4
G
6
Posts: 16
Reputation: 3,527

Post » Wed Feb 29, 2012 12:23 am

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
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Wed Feb 29, 2012 12:36 am

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. ;XTokki2012-02-29 00:46:26
B
13
S
4
G
6
Posts: 16
Reputation: 3,527

Next

Return to How do I....?

Who is online

Users browsing this forum: Colorfish and 4 guests