Abdul Ahmad
Abdul Ahmad

Reputation: 10019

creating empty nodes with boundaries in gamescene.sks

I'm looking at the adventure project by apple to learn how they created the world and other things in the game.

looking at the AdventureWorld.sks file, I see they have a bunch of different "wall" nodes that are placed on top of where the walls are in the image of the background. However, I don't understand how they have created the green rectangles for the empty wall nodes.

I'm adding a new "empty node" to the scene, but how do I create the rectangular shape around the empty node? Also, is this the physics body of the node?

heres what it looks like: http://duxfox.deviantart.com/art/stuff-508377009?ga_submit_new=10%253A1421764250

notice theres a node called "wall" that doesn't have the green rectangle physics body, how do I add this inside an sks file? the other nodes have it somehow

Upvotes: 1

Views: 830

Answers (3)

jiminybob99
jiminybob99

Reputation: 873

The box corresponds to that of non-dynamic physics body. this option is available in the "colour sprite" object's sknode inspector under "physics definition". dynamic bodies are blue, none dynamic bodies are green(different when highlighted). However as I understand, it is not available in the "empty node".

I don't see any extra nodes in the .sks file that would correspond to the expected colornodes so I have no idea apple how managed to do what they did unless they had options that we somehow didn't. A note: The color nodes do not have a name that appears in the view for the .sks. look at the picture and you will see despite having a name in the inspector, the node does not have a name

I hope this helps. If you were able to figure it out. I would like to know

example of colorsprite as physics body, while set on transparent and the physics definition

Upvotes: 1

Jungen yan
Jungen yan

Reputation: 222

I have the same question, and when I was searching the answer, I found when you choose the assistant editor of the sks file, you can find a lot of empty file, choose any one will cause xcode quit.

Upvotes: 0

Sebastian
Sebastian

Reputation: 8164

You can create a solid colored SKSpriteNode with

let node = SKSpriteNode(color: UIColor.greenColor(), size: CGSizeMake(100,100))

Another method is to use SKShapeNode which lets you draw any shape, but note, that it is known to cause memory leaks.

Another option is to create an UIImage with the content you want and make a SKTexture out of it, which you then assign to a SKSpriteNode.

Upvotes: 1

Related Questions