Sprite wont fit in gap that should be big enough

Get help using Construct 2

Post » Tue Sep 10, 2013 7:10 am

Hello all.

I've specifically designed this layout to show my problem.

The layout is 360 wide by 90 high, and I have a platform at 30 high & solid, and a player at 30 high with platform behaviour.

I've snapped the layout to grid 30x30 and I've put the platform at both the top and bottom of the screen, supposedly leaving a 30 high gap in the middle, yes? But will my player fit in there? No he wont.

I cant see any overlap and don't know why he wont fit!

I have the .capx file here - wontfit (grey 'Download This File' button towards the bottom)

Any help much appreciated. I am an utter noob, after all!utternoob2013-09-10 07:13:47
B
5
S
1
G
2
Posts: 17
Reputation: 1,416

Post » Tue Sep 10, 2013 8:36 am

Ok, I can't download, but I'll tell you a secret.

It probably does fit. If you set the coordinates of the player exactly at the x coordinate of the gap it will fall in (that is if your sprites are the same size as in the image editor and their collisionmasks are correct)

if the x coordinate of the player is just a bit of: x is not 100 but 100.001 the sprite won't fall in the gap. While moving your sprite will probably never be at exactly the right coordinate for it to have no collision on the bottom.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Sep 10, 2013 8:35 pm

I see. I think.

I've had a look around but I can't find a way to round them off or use an int(x) alternative. Is there one?

B
5
S
1
G
2
Posts: 17
Reputation: 1,416

Post » Tue Sep 10, 2013 10:33 pm

A 30px high sprite won't fit into 30px high gap since it would be overlapping the sprites above and below. If two sprites share an edge they count as overlapping.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,630

Post » Wed Sep 11, 2013 6:06 am

[QUOTE=ramones] A 30px high sprite won't fit into 30px high gap since it would be overlapping the sprites above and below. If two sprites share an edge they count as overlapping.[/QUOTE]

I'd readily accept that, but can I ask how that relates to my example, here...



My player, blue, moves along the red base freely even though it's sharing an edge along the bottom, but wont go any further into the 30px gap even though at this point it's not sharing an edge with the red platform above-right? (...actually, is it because any further movement right WOULD trigger a collision, so prevents it?)
B
5
S
1
G
2
Posts: 17
Reputation: 1,416

Post » Wed Sep 11, 2013 7:44 am

This is a known issue with the built in platform movement. set the collision polygon slightly smaller then the square and it will fit.
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Thu Sep 12, 2013 7:10 am

<edit: I've removed all behaviours and started from scratch>

Okay, I've shrunk the collision polygon down by a single pixel on all sides and I've created the following events for my player to handle the collision so it doesn't stick when it touches the platform sprite. My player now fits into the gap, but the events required to do this seem ...crude.



I know as long as something works I should be happy, but this looks scrappy to me. Is there an 'accepted' or better way of doing what I'm attempting above?

Many thanks.


Noobutternoob2013-09-12 07:12:09
B
5
S
1
G
2
Posts: 17
Reputation: 1,416


Return to How do I....?

Who is online

Users browsing this forum: plinkie and 2 guests