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-21-2009, 08:01 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 31
Default Call a function in an animation

Alright heres the thing, i have created a game that is questions and buttons that can be tapped. At one point in my game the user can answer a ridiculous question right and if he does he gets a skip. the skips just skips a question.

I have two questions really but the most import is the first. my first question is how do i call an action that i created that is present in the appdelegate (btw my entire application takes place in the app delegate).
Code:
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:1];

	QuesIm2.frame = CGRectMake(0, 0, 200, 200);
	
	QuesIm2.alpha = 1.0;
	
	QuesIm2.frame = CGRectMake(431.0, 291.5, 23, 23);
	
	NSString *path = [[NSBundle mainBundle] pathForResource:@"Skip" ofType:@"au"];
	SystemSoundID soundID;
	AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
	AudioServicesPlaySystemSound (soundID);
	
	CGAffineTransform transform = QuesIm2.transform;
	transform = CGAffineTransformRotate(transform, 3.14159);
	QuesIm2.transform = transform;
	
	transform = CGAffineTransformRotate(transform, 3.14159);
	QuesIm2.transform = transform;	
	
	
	[UIView setAnimationDelay:1];
	QuesIm2.alpha = 0.0;
	skip1.alpha = 1.0;
	QuesIm.alpha=0.0;
	/*
	 how to call an action here
	 */
	[UIView commitAnimations];

	[self.viewController.view addSubview:QuesIm];
	[self.viewController.view addSubview:QuesIm2];
	[self.viewController.view addSubview:skip1];
this is basically what happens when the user answers the skip question right. but i want to know how to call an action so that i can display the next question.

my second question is more complex. i am trying to figure out i can implement my skip button. since this button can be used whenever it needs to skip the question the user is on by calling the function the function that goes to the next question. my question is how to set up strings or something that could be used to call the function of the proper question.

for example say its question 10 then the skip function would take the question number and then add one to it and then call the function of that number but the thing is that my functions are named -(void)Q10Rid)sender so i would need a way to make the 10 change to any number so that the skip could work for every question.

If i wasn't clear please reply telling me so and again, the first questions is more crucial and important since the skips are just fancy things that the game doesn't necessarily need at this moment.

thank
pete42 is offline   Reply With Quote
Old 06-21-2009, 10:59 AM   #2 (permalink)
SuperRoOt
 
Gamer211's Avatar
 
Join Date: Jun 2009
Location: NW Ohio
Age: 30
Posts: 115
Default

*Note: This may not even pertain to what you need to do. Since I am not an appDelegate type of guy.


I'm kind of new to this, but appDelegate is where you're building? But anyway, the one thing I had in this touch game I'm working on, sounds about the same. Although I haven't gotten this far, it seems you may need a UIImage connected to a Text Field where it is hidden until you hit the correct, Skip answer. Then when you get the skip you would need a string to set it to the next question. I think that is how it would work. See in my game I have 3 possibilities on getting a touch right, otherwise you get a "skip" type of screen. Then progresses to the next View. I hope this helped even the slightest bit. If you look up the iTennis blog it shows the UIImage with the hidden text. The code is like this.

// Begin Scoring Game Logic
if(ball.center.y <= 0) {
player_score_value++;
[self resetplayer_score_value >= kScoreToWin)];
}

if(ball.center.y > self.view.bounds.size.height) {
computer_score_value++;
[self resetcomputer_score_value >= kScoreToWin)];
}

} else {
if(tapToBegin.hidden) {
tapToBegin.hidden = NO;
}
}
}



Now you would obviously have to change ball and other tags in the code. But that is what I put in M on ViewController. But then again there are a million ways to do this stuff.
Gamer211 is offline   Reply With Quote
Old 06-22-2009, 04:40 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 31
Default

Thanks, its that simple to call a function. i was doing like [self.viewcontroller.view actionid)sender]; thats why it wasnt working. it didnt really help me with the skip to the next question depending on waht question it is but i have an idea for that. as for the part one of my question 1 of my question, it was stupid i didnt really need to call a function sicne it flows with the game play and i could jsut fade it out.
pete42 is offline   Reply With Quote
Reply

Bookmarks

Tags
action, function, game, string

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
» Online Users: 287
17 members and 270 guests
@sandris, ADY, dacapo, Dani77, djohnson, dre, HemiMG, JasonR, MarkC, mer10, nibeck, prchn4christ, ryandb2, spiderguy84, timle8n1, tomtom100
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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