Guest User

Untitled

a guest
Oct 22nd, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. bool Widget::hitTest(const CCPoint &pt)
  2. {
  3. CCPoint nsp = convertToNodeSpace(pt);
  4. 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);
  5. 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)
  6. {
  7. return true;
  8. }
  9. return false;
  10. }
  11.  
  12. local opactityButton = Button:create()
  13. opactityButton:registerScriptHandler(function (eventType)
  14. -- body
  15. if eventType == "enter" then
  16. print('opactityButton enter')
  17. opactityButton:setEnabled(true)
  18. opactityButton:setTouchEnabled(true)
  19. -- opactityButton:setSizePercent(ccp(0.2, 0.2))
  20.  
  21. opactityButton:setContentSize(aIVSize)
  22. opactityButton:setSize(aIVSize)
  23. opactityButton:setPosition(ccp(400, 400))
  24. opactityButton:setAnchorPoint(ccp(0.5, 0.5))
  25. elseif eventType == "exit" then
  26. print("exit")
  27. end
  28. end)
  29. -- some other codes
  30. local touchGroup = TouchGroup:create()
  31. runningScene:addChild(touchGroup)
Add Comment
Please, Sign In to add comment