我只是希望spritenode在点击时移动。但看起来场景不会更新,直到第二次点击另一个spritenode点击。
我的错误在哪里?
Matrix4 m4 = new Matrix4();
Debug.Log(m4[1, 1]);
答案 0 :(得分:0)
This is how I do what you are trying to do.
I think you should try the nodes(at: ) instead.
here is an example of it in use
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if let touch = touches.first {
//gets location
let location = touch.location(in: self)
//gets of what nodes are at the location
let object = nodes(at: location)
// if the there is a node on that location that is the sprite I want
if object.contains(yourSprite){
//you can put what ever numbers you want to run in there. This simply
// determines the direction of the movement based on a t-Graph
yourSprite.run(SKAction.moveBy(x: 0, y: -5, duration: 1))
}
}