我會盡可能準確地解釋我的問題。在KineticJS中創建具有不同圖層形狀的組
我的項目有2組([Group1],[Group2]) 我想要[Button],它切換[Group1]的可見性。 (setOpacity爲1或0) 我希望[Group1],[Group2]可拖動並彼此固定。
I've tried this way:
I've created 2 layers [Layer1] and [Layer2].
I've added [Group1] to [Layer1]
I've added [Group2] to [Layer2]
When i click [Button], i toggle Opacity of [Layer1]
I've created [MainGroup] and set it to draggable.
I've added [Group1,2] to [MainGroup]. To make them anchored to each other, and i could drag them.
但是,如果使用的不是MainGroup [組別1] .getParent()我得到[層1],這是爲什麼?我應該使用不同的邏輯嗎?我需要[Group1] .getParent()返回[MainGroup],所以我可以在其中找到另一個[Group2]組並添加一些形狀。
我KineticJS版本:4.7.2
您需要張貼一些代碼。在你的問題中,你只提到兩個組,但是你突然提到了第三個主組。是主組內的group1和group2,它又是在一個圖層內? –