1
votes

I'm working on a tangrams game where smaller shapes are placed into a larger shape. The win condition of the game is determined when enough smaller shapes are contained in the larger shape.

I'm wondering how to determine if one SKSpriteNode is completely contained within another SKSpriteNode.

I've looked around on Stack Overflow and on the documentation provided by Apple for Sprite Kit and haven't found a good solution.

Let me know what you think!

1

1 Answers

2
votes

Assuming container is the larger shape and shape is an individual shape, you can determine whether each shape is wholly contained within container as follows:

if (CGRectContainsRect(container.frame, shape.frame))
{
    //....
}

Repeat that for every shape.