Here are the parts of my code that are relevant to this question.
My current issue is I am not detecting any collisions until there are already a bunch of words that have collided. The goal is to have words start at the top of the screen and end just above the onscreen keyboard. If the user accurately types the falling word before it reaches the bottom it is removed from the array and the screen and I will give the user a score. If the words are not typed they will pile up like tetris blocks.
Am I going about this the right way? Should I be looking into a different type of collision detection besides making rectangles out of the word locations?
Thanks in advance.
GameLogic calls addWord() every 3 seconds
this->schedule( schedule_selector(HelloWorld::GameLogic), 3.0);
this->schedule( schedule_selector(HelloWorld::updateGame) );
This is the majority of my addWord() function, each word is a CCLabelBMFont object. Each word is added to the *words CCArray
CCFiniteTimeAction* actionMove = CCMoveTo::create~~>getVisibleOrigin.x + actualX),finalY));
CCFiniteTimeAction* actionMoveDone = CCCallFuncN::create);
CCSequence* moveSequence = );
When a label reaches the bottom of screen, remove the word from theword array and add a rectangle to *wordRect for collision detectoin in update function
CCLabelBMFont **word = sender;
//Make a Rectangle for the current words position
CCRect wordRect = CCRectMake.x - .width/2),
//Cast the above rectangle into a CCValue for array storage
CCValue**wordRectValue = CCValue::valueWithValue;
//Add the rectangle to an array of words that finished their move
//Remove the word from thewords array since the user can no longer interact with this word
updateGame gets the word closest to landing and makes it into a rectangle and checks it against the rectangles in _wordRect for collisions
//Cast first word in array back to CCLabelBMFont
CCLabelBMFont *currentWord = dynamic_cast<CCLabelBMFont>);
//make a rectangle out of the first word in array which should be closest to landing
CCRect currentWordRect = CCRectMake.x - .width/2),
CCValue**wordRectValue = dynamic_cast<CCValue*>;
CCRect finishedWordRect = wordRectValue~~>getValue();
if(finishedWordRect.intersectsRect(currentWordRect) && collisionDetected == false)
//stop current action and create a new action to place current word on top of existing word
collisionDetected = true;