Menus can only be clicked once
Opened this issue · 4 comments
GoogleCodeExporter commented
What steps will reproduce the problem?
1. Launch the MenuTest demo
2. Click on any menu item
3. Try to click any menu item again
Expected: menu items can be clicked repeatedly.
Actual: after first click the menu does not acknowledge further clicks
Tested with version from Jan,25th on both simulator and Nexus One.
Tested this with the MenuTest application shipped with the package aswell
as with my own app, using different menu types, including
MenuItemImage, MenuItemSprite and MenuItemLabel.
Original issue reported on code.google.com by marcelo.emmerich@gmail.com
on 26 Feb 2010 at 10:03
GoogleCodeExporter commented
Not sure this is the actual cause, but the coordinates that are used in the
itemForTouch
function in Menu.java differ between the first and subsequent calls. Especially
the
coordinates in the line
CCPoint local = item.convertToNodeSpace(touchLocation.x, touchLocation.y);
are different and make no sense to me. The subsequent call to containsPoint
does never
return true after the first time.
Original comment by marcelo.emmerich@gmail.com
on 26 Feb 2010 at 12:15
GoogleCodeExporter commented
[deleted comment]
GoogleCodeExporter commented
silly workaround:
private MenuItem itemForTouch(MotionEvent event) {
CCPoint touchLocation =
Director.sharedDirector().convertCoordinate(event.getX(), event.getY());
float menuX = getPositionX();
float menuY = getPositionY();
for (int i = 0; i < children.size(); i++) {
MenuItem item = (MenuItem) children.get(i);
CCRect r = item.rect();
r.origin.x +=menuX;
r.origin.y +=menuY;
if (CCRect.containsPoint(r, touchLocation)) {
return item;
}
}
return null;
}
Original comment by webdev.p...@gmail.com
on 2 Apr 2010 at 3:13
GoogleCodeExporter commented
The problem is the function:
private CCAffineTransform nodeToWorldTransform() {
CCAffineTransform t = nodeToParentTransform();
for (CocosNode p = parent; p != null; p = p.parent)
t.concatenate(p.nodeToParentTransform());
return t;
}
nodeToParentTransform returns a reference to the this.transform_ and the for
loop concatenate inside the variable. The second call concatenate again into
this.transform_ the nodeToParent transforms, so the final transform is fucked.
My solution:
CCAffineTransform t = new CCAffineTransform( nodeToParentTransform() );
Original comment by zhen.sy...@gmail.com
on 13 Aug 2010 at 3:30