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
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 the*word array and add a rectangle to wordRect for collision detectoin in update function
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
CCValuewordRectValue = CCValue::valueWithValue;
//Add the rectangle to an array of words that finished their move
//Remove the word from the*words 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
currentWord = dynamic_cast);
//Cast first word in array back to CCLabelBMFont
//make a rectangle out of the first word in array which should be closest to landing
CCRect currentWordRect = CCRectMake.x - .width/2),
wordRectValue = dynamic_cast*>;
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;