美文网首页
[每记]SK篇-在scene里移动nodes

[每记]SK篇-在scene里移动nodes

作者: 帅气的昵称啊点 | 来源:发表于2018-02-07 22:35 被阅读9次

    scene里有3个方法要重载

    //touch 开始

    override func touchesBegan(_ touches: Set, with event: UIEvent?) 

    //touch 结束

     override func touchesEnded(_ touches: Set, with event: UIEvent?) 

    //touch 移动

     override func touchesMoved(_ touches: Set, with event: UIEvent?) 

    //for 循环应该是控制多点的 未测试确认

    for touch in touches{

            //得到touch的一个location

                let location = touch.location(in: self)

            //得到当前location所在的node

                if let xxx = atPoint(location) as? xxNode

    最后让node的position = location,实现移动

            }

    补充:

    通过在按下抬起 设置zposition,可以让按住的node一直在最上面显示

    相关文章

      网友评论

          本文标题:[每记]SK篇-在scene里移动nodes

          本文链接:https://www.haomeiwen.com/subject/xwqzzxtx.html