Hi there,
Thanks in advance for any help anyone can offer. I'm pretty new to all this.
I come from a background of coding in Actionscript, so maybe I'm approaching this in the wrong way...
Basically, I'm moving a series of balls on the iphone screen. Every time the user taps the screen a new ball is created.
I want to pass each ball an X and Y velocity (let's call them vx and vy) and then move the ball based on these vx and vy values, using a timer.
I can get all of it working fine, except...
How do I pass a newly created ball it's X and Y velocity (vx and vy values).
Like I say, I'm used to Actionscript where I could give an object properties like ball.vx = 10 and ball.vy = 20 and then access those.
I want to be able to do the same thing here but I can't figure it out at all.
I'm passing the ball itself to the function called by the timer using "userInfo" as follows:
Code:
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(moveBall:) userInfo:ballImageView repeats:YES];
But how do I get the initial vx and vy values into each newly created ball? They'll be different each time so I can't use a global variable to store these, and as soon as each ball starts moving I apply gravity to the vy, thereby changing it.
I tried ballImageView.vx = 10 etc. but that didn't work.
Any help would be much appreciated. I know it will be a very simple answer as this is very basic in other programming languages but I've searched everywhere and can't find what I need.
Many thanks.
Ian