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 > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-20-2010, 12:26 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 24
Question Help- MORE problems with coding!

Okay so here's my problem: i want a moving character thats slightly animated, so i came up with a character that uses simple coding and only two images- 1. the image for that character 2. the outline for the object. I used separate images because I want the image to rotate, so the frame might hit an object be4 the users see it to do so, and i couldn't be bothered to create a circular frame. How i'm making him rotate is using a timer, and two actions. Action 1 ("left") is attached to the image of the character via "Touch Down", so it reacts whilst the buttons being pushed. The other ("leftNo") is connected to the same image, via "Touch up inside" and "Touch drag exit". The problem is when i run it, it the timer only runs once? Here's my code:

-(IBAction)start {

direction = 0;

moveHorizontally = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(moveHorizon) userInfo:nil repeats:YES];


[self addSubview:PlayScreen];

}

-(IBAction)left {

direction = 1;

}

-(IBAction)leftNo {

direction = 0;

}

-(void)moveHorizon {

if(direction == 1) {

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.01];
playerImage.transform = CGAffineTransformMakeRotation(0.5);
[UIView commitAnimations];
direction = 1;

}

}

Please help me...
richifie is offline   Reply With Quote
Old 06-20-2010, 01:40 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
Default

Your timer is running fine, but your image only rotates once because you are *setting* the rotating to 0.5 radians each time instead of *adding* 0.5 radians each time. Try this.

Code:
//add 0.5 radians each time
playerImage.transform = CGAffineTransformRotate(playerImage.transform,0.5);
__________________

Free Games!
smasher is offline   Reply With Quote
Old 06-20-2010, 02:24 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2009
Posts: 24
Default

Quote:
Originally Posted by smasher View Post
Your timer is running fine, but your image only rotates once because you are *setting* the rotating to 0.5 radians each time instead of *adding* 0.5 radians each time. Try this.

Code:
//add 0.5 radians each time
playerImage.transform = CGAffineTransformRotate(playerImage.transform,0.5);
TYVM It's working perfectly now.
I can't thank you enough
richifie is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:13 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0