示例#1
0
Block* Block::createWithArgs(Color3B color,Size size,std::string label,float fontSize,Color4B textColor){
    
    auto b = new Block();
    b->initWithArgs(color,size,label,fontSize,textColor);
    b->autorelease();
    
    blocks->pushBack(b);
    
    return b;
}
示例#2
0
Areas* Areas::createWithArgs(Color3B color, Size size, std::string lable, float fontSize, Color4B textColor, int tag){

	auto b = new Areas();
	b->initWithArgs(color, size, lable, fontSize, textColor, tag);
	b->autorelease();

	//添加触摸监听——单点触摸
	auto dispatcher = Director::getInstance()->getEventDispatcher();
	auto listener = EventListenerTouchOneByOne::create();
	listener->onTouchBegan = CC_CALLBACK_2(Areas::onTouchBegan, b);
	//listener->onTouchMoved = CC_CALLBACK_2(NormalMode::onTouchMoved, this);
	//listener->onTouchEnded = CC_CALLBACK_2(NormalMode::onTouchEnded, this);
	listener->setSwallowTouches(false);//向下传递触摸
	dispatcher->addEventListenerWithSceneGraphPriority(listener, b);

	areas->pushBack(b);
	return b;
}