拖动SKNode而不触摸它(Drag and drop SKNode without touching it)
我在SpriteKit上有一个SKNode,我基本上希望能够在屏幕上拖动,但不必触摸它! 想象一下,我在任何地方按屏幕。 然后我希望我的SKNode与我的手指保持距离,这样当我拖动它时我就能看到它。
我有这个工作,但对象抓住了触摸。
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches{ let location = touch.locationInNode(self) circle.position = location } } override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches{ let location = touch.locationInNode(self) circle.position = location } }
I have an SKNode on SpriteKit, which I basically want to be able to drag around the screen, but without having to touch it! Imagine I press the screen anywhere. I then want my SKNode to keep its distance to my finger, so that when I drag it I can see it.
I have this working but the object snaps to the touch.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches{ let location = touch.locationInNode(self) circle.position = location } } override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { for touch in touches{ let location = touch.locationInNode(self) circle.position = location } }
原文:https://stackoverflow.com/questions/37082789
最满意答案
好吧,我解决了我的问题,但我不知道为什么会这样。
我是自学成才,所以我只想尝试一切,直到它起作用。 我能够获得我想要的基类内容:
public void NodeSelected(object sender, DiagramEventArgs e) { Node node = (e.Item as Node); string ders = ((Link_Map.Classes.Links)(((System.Windows.Controls.ContentControl)(node)).Content)).link; Console.WriteLine(ders); }
而
(node)).Content)).link
是我想要的属性,我现在可以从这里访问任何基类属性。如果有人有更好的方法,请发布!
Well, I solved my question but I have no idea why it works.
I'm self taught so I just try everything I can think of until it works. I was able to get the base class content I wanted by:
public void NodeSelected(object sender, DiagramEventArgs e) { Node node = (e.Item as Node); string ders = ((Link_Map.Classes.Links)(((System.Windows.Controls.ContentControl)(node)).Content)).link; Console.WriteLine(ders); }
Whereas the
(node)).Content)).link
was the property I wanted, I can now access any of the base class properties from here.If anyone has a better way, please post!
相关问答
更多-
应该没有 siteNode.SelectSingleNode("//Code")... 但 siteNode.SelectSingleNode("Code")... 这是因为//Code Xpath表达式意味着文档中的“所有”代码“元素”,但您只需要siteNode 。 请参阅Xpath语法示例以供参考。 It should be just not siteNode.SelectSingleNode("//Code")... but siteNode.SelectSingleNode("Code"). ...
-
好吧,我解决了我的问题,但我不知道为什么会这样。 我是自学成才,所以我只想尝试一切,直到它起作用。 我能够获得我想要的基类内容: public void NodeSelected(object sender, DiagramEventArgs e) { Node node = (e.Item as Node); string ders = ((Link_Map.Classes.Links)(((System.Windows.Controls.ContentControl)(node)).Co ...
-
在valueChanged添加以下方法调用printDetails : public void valueChanged(TreeSelectionEvent e) { JTree treeSource = (JTree) e.getSource(); printDetails(e.getNewLeadSelectionPath());//This One TreePath tp = e.getNewLeadSe ...
-
AEM获取子节点内容(AEM Get child node content)[2022-10-19]
我不知道如何获取子节点属性,但也许我有类似的问题因为我想在组件中使用图像。 我试图将图像设置为子节点,但由于我不知道如何访问它,因此无效。 我最终得到的是使用css加载图像。 Using the image base component that comes with AEM helps get guidance on how to access te data. For me it was just a matter to make some modifications and have it worki ... -
查看输出og getSelection(),您会看到使用以下命令获取div容器的完整数据: var text = window.getSelection(); alert(text.anchorNode.data); looking at the output og getSelection() you see that you get the full data of the div container by using the following commmands: var text = windo ...
-
您只需访问attributes属性(NamedNodeMap),您可以在其上调用items以获取字符串键和值: import xml.dom.minidom n = xml.dom.minidom.parseString('
').documentElement attrs = dict(n.attributes.items()) assert attrs == {'a': '1', 'b': '2'} You can simply access the attribute ... -
使用TreeListNodesIterator.DoLocalOperation方法通过特定节点的子节点和TreeListNode.GetValue方法进行迭代,以获取子节点ID。 相关链接: 使用节点迭代器 获取和设置单元格值 Use the TreeListNodesIterator.DoLocalOperation method to iterate via child nodes of specific node and the TreeListNode.GetValue method to obt ...
-
获取所选节点的子计数(Get Child count for selected node)[2023-07-19]
好的,找到了我的答案!! 而不是选择列表我不得不只选择一个节点并使用它的COUNT XmlNode _Node = _Doc.SelectSingleNode("/VolSurface/MTM/Maturity"); int _CNode = _Node.Attributes.Count; 在这个例子中,我正在使用所有节点(大约150多个节点),并且对于每个节点,我正在循环获取属性 XmlNodeList xn = _Doc.SelectNodes("/VolSurface/MTM/Maturity"); ... -
我终于明白了发生了什么。 看看这段代码: var updatedNode = $(selectedNode).addClass('updated'); 这条线实际上有两件事:它向所选节点添加一个类,但它也将这个结果存储在updatedNode中。 到目前为止,DOM应该如下所示:
This is some paragraph.
然后这条线运行: window.parent.tinyMCE.activeEditor.selection.setNode(upda ... -
我通过使用TreeView.SelectedNode.Bounds.X (对于X位置)和TreeView.SelectedNode.Bounds.Y (对于Y位置)并在面板中保留这些动态控件来解决这个问题。 int DistanceFromNode = 250; MyPanel.SetBounds(MyTreeview.SelectedNode.Bounds.X + DistanceFromNode, MyTreeview.SelectedNode.Bounds.Y, MyPanel ...