Commits

Ivan Vučica  committed c6e50c8

Button A. Speed up and dismiss text container.

  • Participants
  • Parent commits 16c75ea

Comments (0)

Files changed (3)

File src/TextContainer.h

   Font * _font;
   NSMutableArray * _queue;
   float _progress;
+  BOOL _buttonA;
 }
+@property (assign) BOOL buttonA;
 - (id) initWithFont: (Font *)font;
 - (void) enqueueText: (NSString *)text;
 - (void) update: (float)dt;

File src/TextContainer.m

 
 #define CD_MIN(x,y) ((x) < (y) ? (x) : (y))
 
+@implementation TextContainer
+@synthesize buttonA=_buttonA;
 
-@implementation TextContainer
 - (id) initWithFont: (Font *)font
 {
   self = [super init];
 {
   if (![_queue count])
     return;
+  if(_buttonA)
+    dt *= 2;
   _progress += dt;
 }
 - (void) draw
 
   glPopMatrix();
 }
+- (void) setButtonA: (BOOL)buttonA
+{
+  if(buttonA && !_buttonA)
+  {
+    [self buttonARises];
+  }
+  _buttonA = buttonA;
+}
+- (void) buttonARises
+{
+  NSLog(@"Button A rises");
+  if(![_queue count])
+    return;
+
+  if(_progress >= 1)
+  {
+    if([_queue count]) [_queue removeObjectAtIndex:0];
+    if([_queue count]) [_queue removeObjectAtIndex:0];
+    _progress = 0;
+  }
+}
 @end

File src/catchdroid.m

 
             if(x / (float)width < 0.10)
               [_scene setDirection: @selector(movePlayerLeft)];
-            else if(x / (float)width > 0.26)
+            else if(x / (float)width > 0.26 && x / (float)width < 0.5)
               [_scene setDirection: @selector(movePlayerRight)];
+            else if(x / (float)width >= 0.5 && x / (float)width < 0.75)
+              [_textContainer setButtonA: YES];
+            else if(x / (float)width > 0.75)
+              {}
             else if(y / (float)height < 0.72)
               [_scene setDirection: @selector(movePlayerUp)];
             else if(y / (float)height > 0.85)
           case AMOTION_EVENT_ACTION_POINTER_UP: 
           case AMOTION_EVENT_ACTION_UP: 
             [_scene setDirection: NULL];
+            [_textContainer setButtonA: NO];
             break;
           default:
           LOGI("New action");