Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Widget::hitTest(const CCPoint &pt)
- {
- CCPoint nsp = convertToNodeSpace(pt);
- CCRect bb = CCRect(-_size.width * m_obAnchorPoint.x - _touchExpandSize.width/2 + _touchExpandOffset.x, -_size.height * m_obAnchorPoint.y - _touchExpandSize.height/2 + _touchExpandOffset.y, _size.width + _touchExpandSize.width, _size.height + _touchExpandSize.height);
- if (nsp.x >= bb.origin.x && nsp.x <= bb.origin.x + bb.size.width && nsp.y >= bb.origin.y && nsp.y <= bb.origin.y + bb.size.height)
- {
- return true;
- }
- return false;
- }
- local opactityButton = Button:create()
- opactityButton:registerScriptHandler(function (eventType)
- -- body
- if eventType == "enter" then
- print('opactityButton enter')
- opactityButton:setEnabled(true)
- opactityButton:setTouchEnabled(true)
- -- opactityButton:setSizePercent(ccp(0.2, 0.2))
- opactityButton:setContentSize(aIVSize)
- opactityButton:setSize(aIVSize)
- opactityButton:setPosition(ccp(400, 400))
- opactityButton:setAnchorPoint(ccp(0.5, 0.5))
- elseif eventType == "exit" then
- print("exit")
- end
- end)
- -- some other codes
- local touchGroup = TouchGroup:create()
- runningScene:addChild(touchGroup)
Add Comment
Please, Sign In to add comment