Sprite wont fit in gap that should be big enough

0 favourites
  • 7 posts
From the Asset Store
2d mushroom sprite 2d game character enmy sprite game art
  • 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!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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 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?

  • 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.

  • 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.

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

    <img src="http://img268.imageshack.us/img268/1112/zlsu.png" border="0" />

    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?)

  • This is a known issue with the built in platform movement. set the collision polygon slightly smaller then the square and it will fit.

  • <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.

    <img src="http://img69.imageshack.us/img69/1576/pkwg.png" border="0" />

    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.

    Noob

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