Skip to content
Discussion options

You must be logged in to vote

所有的碰撞检测都是根据图层内容来的,子图层内容也是这个图层的一部分。没有内容的图层就是空的,没法命中。变通的方法是给组容器加个透明的填充,可以用于响应事件但是不绘制出来。但是目前引擎里的实现好像是过度优化了,计算bounds的时候会考虑是否渲染可见,自动剔除了所有不可见的形状。有两个地方,首先ShapeLayer这个子类应该改为就算fill和strokes都是透明的,也要创建Picture给Layer作为content。其次是Picture内部计算bounds的时候应该要跳过对透明度等不可见属性的判断。这块我们修改一下,改完你给图层加个矩形,然后设置一个透明度为0的fill填充就行了。

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by domchen
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants