基本上,我有一个游戏,要求我调用扩展skpritenode类的对象中包含的两个方法。 我想使用touches begin方法检测节点触摸,从该节点中拉出对对象的引用,然后将该引用分配给touchesBegan方法内部的一个临时变量,该变量可以让我调用其方法。抱歉,如果不清楚,我仍在尝试习惯于“正确”的方式来提出我的问题。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch = touches.first
if(atPoint((touch?.location(in: self))!) == homeButton) && scene?.isPaused == false{
goToHomeG()
}
else {
if let location = touch?.location(in: self){
let theNodes = nodes(at: location)
for node in theNodes{
if node.name == "yesText" {
let transition = SKTransition.flipHorizontal(withDuration: 0.5)
let menuSceneOB = MenuScene(fileNamed: "MenuScene")
menuSceneOB?.scaleMode = .aspectFill
self.view?.presentScene(menuSceneOB!, transition: transition)
node.removeFromParent()
}
else if node.name == "noText" {
for child in self.children {
if child.name == "goToHomeText"{
child.removeFromParent()
}
if child.name == "noText"{
child.removeFromParent()
}
if child.name == "yesText"{
child.removeFromParent()
}
if child.name == "box"{
child.removeFromParent()
}
}
scene?.isPaused = false
}
else if node.name == "enemy"{
//here is where I want to detect if the object is an enemy and then use the assignment to the location to modify the object with its own internal methods.
var modify : EnemyChar?
modify = node
modify.update
}
}
}
}
}
答案 0 :(得分:0)
如果我理解正确,则只需要投射CREATE EXTERNAL TABLE `machine_data`(`ids` string,`delta`
string,`locatio` string,`time_data` string,`valid` boolean,`measure`
string,`val` float
)
PARTITIONED BY (`nodename` string)
CLUSTERED BY (delta) INTO 53 BUCKETS
ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
;
:
node
顺便说一下,这段代码:
else if node.name == "enemy"{
//here is where I want to detect if the object is an enemy and then use the assignment to the location to modify the object with its own internal methods.
var enemy = node as? EnemyChar
enemy.update()
}
可以简化为:
for child in self.children {
if child.name == "goToHomeText"{
child.removeFromParent()
}
if child.name == "noText"{
child.removeFromParent()
}
if child.name == "yesText"{
child.removeFromParent()
}
if child.name == "box"{
child.removeFromParent()
}
}