Cocos2d-x MultipleTouch & CCControllButton'(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-18 11:33 点击:次
p>
p>居然,有一个 setHighlighted方法,这个和 setSelected 方法有什么区别呢? 两个方法所对应的属性应该都是在button选中的吧!疑问
p>
p>带着疑问,继续-----
p>我们找到触摸事件的回调方法(只显示前两个touch began 和 moved 方法):
p>[cpp]
p>bool CCControlButton::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
p>{
p> if (!isTouchInside(pTouch) || !isEnabled() || !isVisible() || !hasVisibleParents() )
p> {
p> return false;
p> }
p>
p> for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
p> {
p> if (c->isVisible() == false)
p> {
p> return false;
p> }
p> }
p>
p> m_isPushed = true;
p> this->setHighlighted(true);
p> sendActionsForControlEvents(CCControlEventTouchDown);
p> return true;
p>}
p>
p>void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
p>{
p> if (!isEnabled() || !isPushed() || isSelected())
p> {
p> if (isHighlighted())
p> {
p> setHighlighted(false);
p> }
p> return;
p> }
p>
p> bool isTouchMoveInside = isTouchInside(pTouch);
p> if (isTouchMoveInside && !isHighlighted())
p> {
p> setHighlighted(true);
p> sendActionsForControlEvents(CCControlEventTouchDragEnter);
p> }
p> else if (isTouchMoveInside && isHighlighted())
p> {
p> sendActionsForControlEvents(CCControlEventTouchDragInside);
p> }
p> else if (!isTouchMoveInside && isHighlighted())
p> {
p> setHighlighted(false);
p>
p> sendActionsForControlEvents(CCControlEventTouchDragExit);
p> }
p> else if (!isTouchMoveInside && !isHighlighted())
p> {
p> sendActionsForControlEvents(CCControlEventTouchDragOutside);
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>