Dynamic Images and Player Moving Image collision Detection
I am working on small game and in that bonus stage is there. There are few stars(UIImageView) available dynamically created. When Player touches those stars it gets points. P开发者_如何学Pythonlayer(UIImageView) can move on sensing accelerometer data from left to right and also can Jump if stars are at some height.
However I am unable to fit the logic for collision between Player and Star Image as those stars are being created dynamically at random positions how to sense intersections between Star and Player.
Should I use some timer which continuously checks for intersection between star and Player? This is not proper solution I believe as it will consume too much memory.
Please suggest me some mechanism so that I can proceed further. How to do this ?
No need for timers, just put your collision detection in the same place where you are handling player movement.(i.e., after you have moved player's UIImageView, test to see if it is touching any star)
(BTW, you should keep an array with references to the available stars to be able to test them for collisions)
精彩评论