How do I repeatedly move an image by 1 pixel?
Posted
by
Will
on Game Development
See other posts from Game Development
or by Will
Published on 2012-03-30T13:33:25Z
Indexed on
2012/03/30
17:44 UTC
Read the original article
Hit count: 190
iphone
|objective-c
I have a method that is moving a UIImageView called shootImg
across the screen:
-(IBAction)shoot{
if (appDelegate.shootInt > 0) {
if (direction == 1) {
shootImg.center = CGPointMake(shootImg.center.x+1, shootImg.center.y);
appDelegate.shootInt = appDelegate.shootInt - 1;
shootLabel.text = [NSString stringWithFormat:@"%d", appDelegate.shootInt];
}
This does seem to work. But it only moves shootImage
1 pixel. What I want to do is make it repeatedly move 1 pixel. I tried a while loop but that didn't seem to work. I'm not using cocos2d or anything like that and if you need to see more code just ask.
Thanks :)
© Game Development or respective owner