ios - Cocos2d bounding box remains zero -
I am creating a toggle switch I have a CCScene that contains a CCLayer with Talkolonged I toggle nodes in sprites and labels. Is shown properly with Touch handling is not working because the box in the toggle node remains zero. I capture the touch in CCLayer (which works with ccTouchBegan: being logged in) and I have this code there:
- (BOOL) ccTouchBegan: (UITT *) Touch Dentor: (UIEvent *) Event {CGPoint Touch Position} [[Self Convert Touchs Nodespace: Touch]; NSLog (@ "Bounding Box:% F,% F,% F,% F", Toggle Node. Barring Box.Orgine.x, Toggle Node. Barring BoxOrigin., Toggle Node .baring BoxOrgin + + Toggle Node .barring box. Width, toggleNode.boundingBox.origin.y + toggleNode.boundingBox.size.height); NSLog (@ "Touch:% F,% F", Touch Location.x, Tutorial). If (CGRectContainsPoint (toggleNode.boundingBox, touchpad)) {[toggleNode toggle]; } no return; }
Results in one touch at ToggleNode:
Bounding box: 512.000000, 384.000000, 512.000000, 384.000000 touch: 508.000000, 378.000000
I believe the bounding box is zero. but why? Having a problem? I'm still learning in Cocos 2D but I do not think it's normal behavior.
If CCNode is obtained from the toggle, this behavior is normal. A CCNode has a 0-size binding box and the content size is also zero.
If you get your class from CCNode, then it is for you content content set (also updates the bounding box)
Only if you use a class Those who use a texture (CCSprite, CCLabelTTF and others), cocos2d has set up ContentSize itself.
Comments
Post a Comment