Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a different approach, using a state or control variable for the view, to determine what it should do next given the button presses.</p> <pre><code>// pseudo-code based on your example -(IBAction) buttonPress1 if (a) { do something self.setState = stateA; } else if (b) { do something else self.setState = stateB; } -(IBAction) buttonPress2 if (self.state == stateA) { if (a) { do something } else if (b) { do something } } </code></pre> <p>hope that helps, if not, ask away in the comments.</p> <hr> <p>[EDIT]</p> <p>OK, after you explained the DA/ME/ME2 reference I get what you're looking for.</p> <p>What you're maybe going to want to do, is store your Dialogue in a plist, to load into a NSDictionary. (read up on NSDictionary)</p> <p>Each NSDictionary should look like this:</p> <p>key = value</p> <p>@"prompt" = @"hi my name is bob" @"MEAN" = NSDictionary object for next convo choice for mean @"NICE" = NSDictionary object for next convo choice for nice</p> <pre><code>const BOOL NICE = YES; const BOOL MEAN = !NICE; NSDictionary *convo = //loaded to initial starting point from your plist file - (IBAction) playerChoseMean:(id)sender { [self sayConvo:convo withChoice:MEAN]; } - (IBAction) playerChoseNice:(id)sender { [self sayConvo:convo withChoice:NICE]; } - (void) sayConvo:(NSDictionary)convo withChoice:(BOOL)b { NSLog(@"NPC says: %@", [convo valueForKey:@"prompt"]); if(b) { convo = (NSDictionary*)[convo valueForKey:@"NICE"]; } else { convo = (NSDictionary*)[convo valueForKey:@"MEAN"]; } if (convo == [NSNull null] || convo == nil) then continue; //else continue } </code></pre> <p>Here's an example NSDictionary graph which should get you started.</p> <pre><code>NSDictionary *intro = [NSDictionary dictionaryWithCapacity:3]; NSDictionary *nice = [NSDictionary dictionaryWithCapacity:3]; NSDictionary *nicenice = [NSDictionary dictionaryWithCapacity:3]; NSDictionary *nicegoodbye = [NSDictionary dictionaryWithCapacity:3]; NSDictionary *mean = [NSDictionary dictionaryWithCapacity:3]; NSDictionary *meangoodbye = [NSDictionary dictionaryWithCapacity:3]; [intro addValue:@"hi there!" forKey:prompt]; [intro addValue:nice forKey:@"NICE"]; [intro addValue:mean forKey:@"MEAN"]; [nice addValue:@"that was nice" forKey:prompt]; [nice addValue:nicenice forKey:@"NICE"]; [nice addValue:mean forKey:@"MEAN"]; [nicenice addValue:@"awww" forKey:prompt]; [nicenice addValue:nicegoodbye forKey:@"NICE"]; [nicenice addValue:mean forKey:@"MEAN"]; [nicegoodbye addValue:@"you were super nice, here's a bonus for being so nice" forKey:prompt]; [nicegoodbye addValue:[NSNull null] forKey:@"NICE"]; [nicegoodbye addValue:[NSNull null] forKey:@"MEAN"]; [mean addValue:@"that was mean" forKey:prompt]; [mean addValue:nice forKey:@"NICE"]; [mean addValue:meangoodbye forKey:@"MEAN"]; [meangoodbye addValue:@"you're a jerk! goodbye!" forKey:prompt]; [meangoodbye addValue:[NSNull null] forKey:@"NICE"]; [meangoodbye addValue:[NSNull null] forKey:@"MEAN"]; </code></pre> <hr> <p>Take a look at this excellent example over on <a href="https://gamedev.stackexchange.com/questions/31/how-can-i-implement-dialog-trees-into-my-game">GameDeve.SE</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload