How do I Stop the player from leaving the screen

Just started using Construct 2? Post your questions here

Post » Sat Dec 10, 2016 2:05 pm

Hi

My player sprite is made up of three parts (because the collision area is only meant to work with one part of the player is why this is) and so when it is dragged, I have had to unpin and re pin the objects each time.

I am trying to stop the player object(s) from leaving the "player area" and have tried to add the behaviour bound to layout but this still seems to A) allow the player object(s) leave the bottom section of the game area and b) when the top part of the player object reaches the top part of the game area, the player object starts to be pushed around so that the "head" part of the object drops and the "handle" part of the object because parallel to it. This is really hard to explain but in essence instead of the objects all keeping together and just stopping when they hit the stop, they start to be pushed apart.

Any thoughts how to overcome this please?


Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Sat Dec 10, 2016 2:08 pm

There is probably some smart way of doing this but in my game when like a boss battle started that was only on 1 screen, I simply placed walls around the window and made them invisible and 1 px wide
B
21
S
9
G
8
Posts: 188
Reputation: 6,069

Post » Sat Dec 10, 2016 2:25 pm

Hi Triforce

Thanks for this suggestions, I stupidly forgot to mention that I have random enemies that spawn off screen and then move towards targets that are on screen. If I created these "walls" which I suspect would then have collision as well, would these stop the enemies from entering the gaming screen ?

Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Sun Dec 11, 2016 7:17 am

I have tried the following to get this to work, created a sprite called borders and simply fill this as a colour , then added a solid behaviour to it and for testing set one part of the player as a platform player. Took out the gravity as I do not need this and it seemed to work but now and again, it would allow the player to pass through the "solid" object any reason why this would be ?

Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Sun Dec 11, 2016 7:27 am

A screenshot would be nice.
B
27
S
6
G
5
Posts: 18
Reputation: 3,967

Post » Sun Dec 11, 2016 10:50 am

LoneVox wrote:A screenshot would be nice.


Sorry to be secretive LoneVox I am trying to keep this project under wraps at the moment.

If you are after a screen shot of the level 1 design , then it is simply something like the attachment provided could not see a way to attach it other than a link to an URL this may not say on line for too long however Image

Here are the settings for the player :
Image

And here is the settings for the borders :

Image




Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Sun Dec 11, 2016 1:46 pm

Its not working the bound to layout behavior? Also, checking if the item is overlapping the wall before running its events should be enough.

Sample CAPX: https://dl.dropboxusercontent.com/u/470 ... %20AI.capx
Last edited by TELLES0808 on Sun Dec 11, 2016 2:35 pm, edited 1 time in total.
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Sun Dec 11, 2016 2:19 pm

TELLES0808 wrote:Its not working the bound to layout behavior? Also, checking if the item is overlapping the wall before running its events should be enough.


This is what I tried first but as mentioned this causing other issues.

With regards the overlapping check when you say "before running its events" what do you mean by this ? which object and what events


Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Post » Sun Dec 11, 2016 2:35 pm

Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Sun Dec 11, 2016 10:51 pm

TELLES0808 wrote:I did a sample for you: https://dl.dropboxusercontent.com/u/470 ... %20AI.capx



Thanks TELLES0808 willl look at this and see if it solves my problem


Thanks

TimCS
Regards

TimCS
B
22
S
8
Posts: 119
Reputation: 1,870

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests