Edit clone's variable in Scenekit
up vote
0
down vote
favorite
I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".
Here is my complete code :
@objc func createInfoPanels(climName: String) -> SCNNode {
let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!
let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear
let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4
let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear
let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0
let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1
skScene.addChild(rectangle)
skScene.addChild(labelNode)
let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene
planeGeometry.materials = [panelMaterial]
climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]
return planeNode
}
Thanks in advance for your help!
swift sprite-kit clone scenekit
add a comment |
up vote
0
down vote
favorite
I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".
Here is my complete code :
@objc func createInfoPanels(climName: String) -> SCNNode {
let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!
let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear
let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4
let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear
let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0
let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1
skScene.addChild(rectangle)
skScene.addChild(labelNode)
let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene
planeGeometry.materials = [panelMaterial]
climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]
return planeNode
}
Thanks in advance for your help!
swift sprite-kit clone scenekit
where is clone function?
– Simone Pistecchia
22 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".
Here is my complete code :
@objc func createInfoPanels(climName: String) -> SCNNode {
let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!
let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear
let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4
let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear
let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0
let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1
skScene.addChild(rectangle)
skScene.addChild(labelNode)
let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene
planeGeometry.materials = [panelMaterial]
climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]
return planeNode
}
Thanks in advance for your help!
swift sprite-kit clone scenekit
I created a function which create a circle containing a label. I need to clone this function multiple times. Via the clone() function I can make a copy of the complete geometry, works great.
Now I need for each clone to edit the text label. My issue is here, how to edit something which is "created" once to be clone after? How can I access to the clone variables and in my case the "labelNode.text".
Here is my complete code :
@objc func createInfoPanels(climName: String) -> SCNNode {
let climNode = self.scene.rootNode.childNode(withName: climName, recursively: true)!
let planeGeometry = SCNPlane(width: 1, height: 1)
planeGeometry.firstMaterial?.diffuse.contents = NSColor.clear
let planeNode = SCNNode(geometry: planeGeometry)
planeNode.name = "planeNode"
planeNode.position.y = 4
let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = NSColor.clear
let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 100)
rectangle.fillColor = .gray
rectangle.alpha = 0.8
rectangle.blendMode = .add
rectangle.lineWidth = 0
let labelNode = SKLabelNode()
labelNode.text = "°C"
labelNode.fontSize = 45
labelNode.position = CGPoint(x: 100, y: 100)
labelNode.yScale = -1
skScene.addChild(rectangle)
skScene.addChild(labelNode)
let panelMaterial = SCNMaterial()
panelMaterial.isDoubleSided = false
panelMaterial.diffuse.contents = skScene
planeGeometry.materials = [panelMaterial]
climNode.addChildNode(planeNode)
planeNode.constraints = [SCNBillboardConstraint()]
return planeNode
}
Thanks in advance for your help!
swift sprite-kit clone scenekit
swift sprite-kit clone scenekit
asked 2 days ago
Silvering
129113
129113
where is clone function?
– Simone Pistecchia
22 hours ago
add a comment |
where is clone function?
– Simone Pistecchia
22 hours ago
where is clone function?
– Simone Pistecchia
22 hours ago
where is clone function?
– Simone Pistecchia
22 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373190%2fedit-clones-variable-in-scenekit%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
where is clone function?
– Simone Pistecchia
22 hours ago