Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-27-2009, 06:24 PM   #21 (permalink)
LeopardDevX
iPhone Developer
 
Join Date: Mar 2009
Posts: 222
Arrow but...

Quote:
Originally Posted by smasher View Post
I can't see your code, so I don't know what variables you have If you have a speedY variable, then you can use that to get the new position of the enemy.

So, this code will loop through every enemy in the array, and move them all down the screen by "speedY" :
Code:
for (UIView *anEnemy in enemies){
float newX = anEnemy.center.x;
float newY = anEnemy.center.y +speedY;
anEnemy.center = CGMakePoint(newX, newY);
}
"anEnemy" is just a pointer I use when looking through the array of enemies. It's not a new object or anything, it's just used to point to the existing enemies in the array. We need a pointer so we can give everyone in the array a new position.


Code:
 warning: local deceleration of "newEnemy"    hides instance variable.
This means that you already have a variable (instance variable) called "newEnemy."
The compiler is complaining that I declared a new variable (local variable) with the same name. There are two ways to fix it -
(1) remove "UIImageView *" from the front of that line, so it doesn't declare a new variable. It will just use the existing variable instead.
or (2) change the name of the local variable (the new one declared on that line.) That will leave the

The correct step to take depends on what your code is doing. Are you trying to affect the instance variable, or just a local one? In my examples, changing the name of the local variable should do the trick (option 2).

but how does that make the newEnemy move.... because currently it doesnt....

__________________
Thank You.
LeopardDevX is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,736
Threads: 89,192
Posts: 380,536
Top Poster: BrianSlick (7,129)
Welcome to our newest member, wrapsol
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.