set SKEmitterNode to background
I am setting up a scene with a fixed background (a simple rectangle), an SKEmitterNode, and a backgroundLayer (a SKNode including many SKShapeNodes) : this is the hierarchy of my scene. But, even if I am adding the emitter node as a child of the scene just after the fixed background and just before the background layer, the particles emitted are at the foreground, which is not what I am expecting. indeed, I would like them to be rendered between the fixed background and the background layer, which is not happening.
I am running this app on ios 10. I've tried to add childs in a different order, or to change the target node, but it didn't change anything...
All of the following code comes from 'init(size: CGSize) {}' of a scene class which inherits from SKScene.This is all the scene set up process (when childs are added).
anchorPoint = CGPoint(x: 0, y: 0)
background.position = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
background.fillColor = UIColor(white: 0.5, alpha: 1)
background.strokeColor = UIColor.lightGray
addChild(background)
setUpParticleEmitter() // it sets up the particle emitter which is an attribute of the class
addChild(backgroundEmitter) // This is the name of the emitter
backgroundEmitter.targetNode = scene
backgroundLayer.position = CGPoint(x: 0, y: 0)
addChild(backgroundLayer)
gameLayer.position = CGPoint(x: -1 * sceneSize.width, y: 0) // another layer for futur nodes
addChild(gameLayer)
I expect the particles to be rendered between 'background' and 'backgroundLayer', but they are rendered at the foreground (=over the backgroundLayer's childs), is it possible to change that ?
swift xcode sprite-kit skscene skemitternode
add a comment |
I am setting up a scene with a fixed background (a simple rectangle), an SKEmitterNode, and a backgroundLayer (a SKNode including many SKShapeNodes) : this is the hierarchy of my scene. But, even if I am adding the emitter node as a child of the scene just after the fixed background and just before the background layer, the particles emitted are at the foreground, which is not what I am expecting. indeed, I would like them to be rendered between the fixed background and the background layer, which is not happening.
I am running this app on ios 10. I've tried to add childs in a different order, or to change the target node, but it didn't change anything...
All of the following code comes from 'init(size: CGSize) {}' of a scene class which inherits from SKScene.This is all the scene set up process (when childs are added).
anchorPoint = CGPoint(x: 0, y: 0)
background.position = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
background.fillColor = UIColor(white: 0.5, alpha: 1)
background.strokeColor = UIColor.lightGray
addChild(background)
setUpParticleEmitter() // it sets up the particle emitter which is an attribute of the class
addChild(backgroundEmitter) // This is the name of the emitter
backgroundEmitter.targetNode = scene
backgroundLayer.position = CGPoint(x: 0, y: 0)
addChild(backgroundLayer)
gameLayer.position = CGPoint(x: -1 * sceneSize.width, y: 0) // another layer for futur nodes
addChild(gameLayer)
I expect the particles to be rendered between 'background' and 'backgroundLayer', but they are rendered at the foreground (=over the backgroundLayer's childs), is it possible to change that ?
swift xcode sprite-kit skscene skemitternode
add a comment |
I am setting up a scene with a fixed background (a simple rectangle), an SKEmitterNode, and a backgroundLayer (a SKNode including many SKShapeNodes) : this is the hierarchy of my scene. But, even if I am adding the emitter node as a child of the scene just after the fixed background and just before the background layer, the particles emitted are at the foreground, which is not what I am expecting. indeed, I would like them to be rendered between the fixed background and the background layer, which is not happening.
I am running this app on ios 10. I've tried to add childs in a different order, or to change the target node, but it didn't change anything...
All of the following code comes from 'init(size: CGSize) {}' of a scene class which inherits from SKScene.This is all the scene set up process (when childs are added).
anchorPoint = CGPoint(x: 0, y: 0)
background.position = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
background.fillColor = UIColor(white: 0.5, alpha: 1)
background.strokeColor = UIColor.lightGray
addChild(background)
setUpParticleEmitter() // it sets up the particle emitter which is an attribute of the class
addChild(backgroundEmitter) // This is the name of the emitter
backgroundEmitter.targetNode = scene
backgroundLayer.position = CGPoint(x: 0, y: 0)
addChild(backgroundLayer)
gameLayer.position = CGPoint(x: -1 * sceneSize.width, y: 0) // another layer for futur nodes
addChild(gameLayer)
I expect the particles to be rendered between 'background' and 'backgroundLayer', but they are rendered at the foreground (=over the backgroundLayer's childs), is it possible to change that ?
swift xcode sprite-kit skscene skemitternode
I am setting up a scene with a fixed background (a simple rectangle), an SKEmitterNode, and a backgroundLayer (a SKNode including many SKShapeNodes) : this is the hierarchy of my scene. But, even if I am adding the emitter node as a child of the scene just after the fixed background and just before the background layer, the particles emitted are at the foreground, which is not what I am expecting. indeed, I would like them to be rendered between the fixed background and the background layer, which is not happening.
I am running this app on ios 10. I've tried to add childs in a different order, or to change the target node, but it didn't change anything...
All of the following code comes from 'init(size: CGSize) {}' of a scene class which inherits from SKScene.This is all the scene set up process (when childs are added).
anchorPoint = CGPoint(x: 0, y: 0)
background.position = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
background.fillColor = UIColor(white: 0.5, alpha: 1)
background.strokeColor = UIColor.lightGray
addChild(background)
setUpParticleEmitter() // it sets up the particle emitter which is an attribute of the class
addChild(backgroundEmitter) // This is the name of the emitter
backgroundEmitter.targetNode = scene
backgroundLayer.position = CGPoint(x: 0, y: 0)
addChild(backgroundLayer)
gameLayer.position = CGPoint(x: -1 * sceneSize.width, y: 0) // another layer for futur nodes
addChild(gameLayer)
I expect the particles to be rendered between 'background' and 'backgroundLayer', but they are rendered at the foreground (=over the backgroundLayer's childs), is it possible to change that ?
swift xcode sprite-kit skscene skemitternode
swift xcode sprite-kit skscene skemitternode
asked Jan 18 at 17:43
SethSeth
32
32
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can chose which nodes to be in front and which in back by setting them the zPosition.
first_node.zPosition = 1
second_node.zPosition = 2 // displayed over first node
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f54259013%2fset-skemitternode-to-background%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can chose which nodes to be in front and which in back by setting them the zPosition.
first_node.zPosition = 1
second_node.zPosition = 2 // displayed over first node
add a comment |
You can chose which nodes to be in front and which in back by setting them the zPosition.
first_node.zPosition = 1
second_node.zPosition = 2 // displayed over first node
add a comment |
You can chose which nodes to be in front and which in back by setting them the zPosition.
first_node.zPosition = 1
second_node.zPosition = 2 // displayed over first node
You can chose which nodes to be in front and which in back by setting them the zPosition.
first_node.zPosition = 1
second_node.zPosition = 2 // displayed over first node
answered Jan 18 at 18:30
Alexandru VasiliuAlexandru Vasiliu
14412
14412
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f54259013%2fset-skemitternode-to-background%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