'Why doesn't sprite kit detect my second "collision"
- Assume I have all my physics body and dynamic properties set properly
- I have a player and a wall
- When I swipe right, the user hits the wall, and stops, and Xcode detects that collision.
- The problem im facing is that since the user is now against the wall, when I swipe right again, it doesn't detect the collision but you can still see the player trying to goto the right bumping it. This why I quoted collision since it technically is not a collision but it should be since the user is trying to move to the right
Is my issue something not supported by sprite kit?
Solution 1:[1]
I suspect it's because didBegin(contact:) fired when you hit the wall but you are still hitting the wall, therefore didEnd(contact:) hasn't fired and so you can't start a new contact.
Remember it's not a collision but a contact - collisions are when one object bounces off another and are handled by the SK game engine; contacts are when one object touches another and are handled by user code.
Do you have collisions enabled between the user and the wall? If not, the 2 sprites can overlap and the contact won't end. You might have to set up collisions and have the user bounce off the wall slightly, thus ending the contact and enabling another contact to be detected.
Alternatively you can set a flag in didBegin(contact:) which you clear in didEnd(contact:) and take some action every time the user swipes and the flag is still set (the contact hasn't ended).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
