Now our normalizedPosition implementation only works when the parent’s contentSize is dirty.
uint32_t flags = parentFlags;
flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0);
flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0);
if(_usingNormalizedPosition && (flags & FLAGS_CONTENT_SIZE_DIRTY)) {
CCASSERT(_parent, "setNormalizedPosition() doesn't work with orphan nodes");
auto s = _parent->getContentSize();
_position.x = _normalizedPosition.x * s.width;
_position.y = _normalizedPosition.y * s.height;
_transformUpdated = _transformDirty = _inverseDirty = true;
}
But suppose we have the following code : I want to change child’s normalizedPosition in ccTouchBegain callback.
auto parent = Node::create();
auto child = Node::create();
parent->addChild(child);
onTouchBegain()
{
child->setNormalizedPosition(xxx); // it won’t work because it’s parent’s content size doesn’t change.
}
Any suggestions? Anything missing here?
Thanks.
--
You received this message because you are subscribed to the Google Groups "cocos2d JS development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cocos2d-js-dev...@googlegroups.com.
To post to this group, send email to cocos2d-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.