Hi. I recently created a game where you tilt the device to avoid falling rocks. The problem is, when the rocks fall, I have it set to when they are off the screen, they will fall randomly from back at the top. The only thing is that when it does this, it flashes really fast on the screen where it is going to fall, then it falls. Here is the code:
I would expect your code to pop the rock back to the top of the screen; half off the top actually.
What is it really doing? I don't understand "it flashes really fast on the screen where it is going to fall, then it falls." Can you explain it another way? Slow down your framerate so you can see what's really happening if you need it.
I would expect your code to pop the rock back to the top of the screen; half off the top actually.
What is it really doing? I don't understand "it flashes really fast on the screen where it is going to fall, then it falls." Can you explain it another way? Slow down your framerate so you can see what's really happening if you need it.
It flashes in the middle of the screen of where it is going to fall on the y axis. So basically, you can see it for a split second in the middle of the screen then it falls from the top of the screen directly above from where it flashed. Sorry. It's kind of hard to explain. If you still don't get what I'm trying to say, I can record the screen then post it to youtube.
How are you moving your items? Are you using an NSTimer? Is it possible that this code is inside a beginAnimations/commitAnimations block? It sounds like it might be "animating" to the new position instead of moving instantly.
How are you moving your items? Are you using an NSTimer? Is it possible that this code is inside a beginAnimations/commitAnimations block? It sounds like it might be "animating" to the new position instead of moving instantly.
I am using both an NSTimer and a beginAnimations/commitAnimations block. Here's the code:
If you comment out the beginAnimations/commitAnimations, does the problem go away? I haven't mixed UIView animations with NSTimers, but I suspect that's the issue.
It's not related to the problem, but you might also consider using *one* timer that calls a gameUpdate() method, and an array of rocks instead of separate rock variables and methods. Your code will be shorter and easier to update.
If you comment out the beginAnimations/commitAnimations, does the problem go away? I haven't mixed UIView animations with NSTimers, but I suspect that's the issue.
It's not related to the problem, but you might also consider using *one* timer that calls a gameUpdate() method, and an array of rocks instead of separate rock variables and methods. Your code will be shorter and easier to update.
The problem does go away! The only thing is now one of the rocks stops at the top and then falls about 2 seconds later. I'll figure it out from here though. And thanks for the suggestion. I will do that as well! Again, thanks!
The problem does go away! The only thing is now one of the rocks stops at the top and then falls about 2 seconds later. I'll figure it out from here though. And thanks for the suggestion. I will do that as well! Again, thanks!
Actually, I figured out that I only commented out the one rock that was stalling and then falling. now all of them stall then they all fall at once.
Actually, I figured out that I only commented out the one rock that was stalling and then falling. now all of them stall then they all fall at once.
You're gonna kill me, but I figured out what was wrong. I cut out the part that wasn't part of the animation. I'm so sorry. You did have it right to begin with. Once again, thanks! Sorry i'm so noobish. lol