Hollow sprites/shapes?

0 favourites
  • 7 posts
From the Asset Store
Template for an alternative to falling shapes, fully documented in comments and video
  • Hi all,

    Still learning but have a relatively basic (i hope) question for everyone. I have a shape that I want to be hollow e.g. a square and it has a another shape inside it e.g. a circle. What I want to do is be able to move the circle around the inside of the square and be contained to that area. I can move the circle around easily enough with behaviours but i'm not sure about the square, should it even be a sprite? I can't make the square a solid as the circle then appears outside the square. Is the alternative to add in some "hidden" sprites that would mark out the collision area of the edge of the square?

    I've had a look on the forums and tutorials but i'm not even sure i'm calling it the correct thing to find the correct answer.

    Cheers!

  • Hey partTimeCrazy,

    Not completely sure I know what you're after! But if you want to limit the movement of your circle sprite, to be contained within your square sprite. You could try adding a condition to only move the circle sprite if touch/click etc, is within the boundaries of the square sprite.

    If I've completely misunderstood what you're trying to achieve, it may be worth adding a capx, so that others can more easily understand the problem.

    Good luck :)

  • Look into the 'blend modes' example capx, I think that may be what you're after.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • something like that?

    squareConstraint.capx

  • Yann has the right idea but i'm not sure how to do that if the square in the example is an irregular shape? Basically the square needs to only have an outline of the square i.e. walls and the circle can only move inside those walls.

    I'm thinking I may be better off making each "wall" a sprite in itself and having collision detection on it that way. I thought there might have been an easy way to have a single sprite with a hollow center but I may be over thinking it.

    Thanks for the responses anyway! Its nice to see such a helpful forum!

    <img src="smileys/smiley20.gif" border="0" align="middle" />

    Also Yann, those Reddit Videos are awesome!

  • If you want some thing more complex, like having any shape constrained inside any other shape, it becomes more complex.

    It would be slightly easier if we had access to the position of the collision polygon's vertices.

    Then we could do some math ourself to check if one of the point of the dragged object is outside of the constraining shape.

    Then it would be a matter of keeping in memory the previous position of the object and interpolating between this position and the position the object would be if there were no constraint by running a loop to approximate the position the shape should be to stay within the constraints.

    Using multiple objects to build the constraining area would be a possible solution but, to me, it would look quite messy to set up.

  • the polygon zone is always completly filled, it could work if we could cut holes with a polygon mesh) but now the only way is to construct multiple walls, pin them together and have a cirle inside the zone. well if thats what your after..

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