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:17 PM   #20 (permalink)
smasher
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Quote:
Originally Posted by LeopardDevX View Post
I dont get this method.. what is anEnemy and i allready have a speedY float that controlls enemy movement.....
The enemy is just moving down the Y axe,
so can you explain??

And those warnings.. i told you about what about Them???

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 = CGPointMake(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).
__________________

Free Games!

Last edited by smasher; 03-27-2009 at 09:34 PM.
smasher is offline   Reply With Quote
 

» Advertisements
» Online Users: 275
19 members and 256 guests
ADY, aikhan, AppAnnex, astalavista, chemistry, HemiMG, ilmman, MarkC, mer10, nicko, NSeven, padsoftware, Paul10, pavanindira, Promo Dispenser, Raffaello, RoryHarvey, timle8n1, touchcream
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,877
Threads: 89,219
Posts: 380,707
Top Poster: BrianSlick (7,129)
Welcome to our newest member, peterkessler45
Powered by vBadvanced CMPS v3.1.0

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