I got the following question. I have two objects on my Subview. One of them is a player who is able to move on tiles. The other one is a wall. The player should not be able to move through or on the wall. Right now the wall is seen as nothing or a background (not a obstacle). One idea I have is saving all the coordinates of the walls and checking if the coordinates of the player match the coordinates of a wall and undo the movement. In my eyes this idea is pretty inefficient and could probably done better. Are there any other solutions?
1 Answers
0
votes
If this is a game, use Sprite Kit, which gives you collision detection and automatic "bounce" behavior. If it is momentary animation, use UIKit Dynamics, which gives you collision detection and automatic "bounce" behavior. Otherwise, you just have to implement collision detection yourself (by looking to see whether the frame of one view intersects the frame of another) and perform the "bounce" yourself.