so at the befinning i would like to set image x,y coordinates to 150 BUT later in gameloop a want to change position of image, but it don't respond (stay on the 150,150), so, is the gameloop under viewdidload or viewdidload always set 150,150 for each time?
(ahax, ahay are defined in .h file (to have "global" access to him.. if i understand this good..)
and what is that time in NSTimet: 0.033? it is in hours or..?
edit:
Code:
the gameloop looks like
if (accelx.... < 0.1.... for example)
{
ahax += (accelx*5)
}
image.center = ahabod;
...
so image should move...
Last edited by vogueestylee; 02-19-2011 at 01:10 PM.
You have two questions and I'll try to hit them both.
>is the viewDidLoad {} function goes only for first time of app start?
No, viewDidLoad get called *if* the view is not already loaded when someone asks for thatController.view. It will always be called at least once when you display the view. If you re-use the viewController then it *may* get called again, but only if the view was unloaded as result of a memory warning.
Your second question - why is image not moving - seems to be because you are not changing the values in ahabod. It looks like you set them once and then never change them again.
If you xacc to be a string, then the second one is correct. This first one works if xacc is a float or int.
Quote:
so, is there any good way how to define (void) that will go
only first time and then never repeat in program?
Can you ask again, in a different way? I don't know what "define (void)" means. When you see "void" in Objective-C it usually refers to a method that returns nothing.
Have you tried setting a breakpoint in XCode and debugging? Or at the very least, writing print statements and checking the console?
Hi all, this is good idea. when i was just curious, what is stored in "acc.x" i made a label a set writing a number on it, bud it was just for check the value, i think, there must be the way that appliciation is running in my mobile (emulator) and on the macbook i see value of acc.x for example on console or so on.. how to do that? it will save a lot of time of not doing these unnecessary Label on iphone screens..
Smasher - what i was thinking, you run the application, it set up image basic coordinates to 150.0,150.0 and show the pictire, but then it never again set up 150.0,150.0 but coordinates stay 150.0,150.0 or are changed by any other void in application. do you understand better what i'm affraid of? to not set up it again in the middle of program, bud i maybe understood what you wrote that - if i don't "close" the actual view, then viewDidLoad goes only once (what i need) and NSTimer loop goes "for ever" (what i need)..
i now "playing" with moving of picture should see more realistic, need to implement speed + acceleration*time^2 something like that, bud having problems with time, really have no clue how to set it and read it and how to set an inertia to object so maybe i will ask later