CCMenuItemImage* Objects2dFactory::clickableRectangle(CCNode* scene, CCMenu* menu, ccColor3B color, float positionX, float positionY, float width, float height, SEL_MenuHandler selector, void* selectorArg, AlignX alignX, AlignY alignY, GLubyte opacity, int zOrder) { // Check arguments validity if(scene == NULL || menu == NULL || !selector) return NULL; // Create a button menu item CCMenuItemImage *button = CCMenuItemImage::create("TopQXResources/white.png", "TopQXResources/white.png", "TopQXResources/white.png", scene, selector); if(!button) return NULL; // Set argument if (selectorArg != NULL) { button->setUserData(selectorArg); } // Set color button->setColor(color); // Set opacity button->setOpacity(opacity); // Place the menu item in the given position button->setPosition(ccp(positionX, positionY)); // Set anchor button->setAnchorPoint(ccp(Constants::getAnchorValue(alignX), Constants::getAnchorValue(alignY))); // Set menu item width float buttonWidth = button->boundingBox().size.width; button->setScaleX(width / buttonWidth); // Set menu item height float buttonHeight = button->boundingBox().size.height; button->setScaleY(height / buttonHeight); // Add button to the menu menu->addChild(button, zOrder); return button; }