Friday Discount - Lifetime Access for $20!!!! - Click Here!

Add / Remove Events – Story Tellers iOS Starter Kit Documentation

Events for Adding and Removing Nodes

Story Tellers iOS Starter Kit 2 Documentation

Adding or showing hidden nodes at runtime is an important part of any app. You’ll probably find the easiest thing to do is simply move Elements out of the visible area and set their Hidden property to YES. Then when needed, use the Show property and move the Element where you want it.  But if that’s too much clutter, you can add an Element from ANY other Scene (.sks) file using the Add property….

  • Add – Create a Dictionary named Add, then include the two required properties, FromFile and WithName to identify the .sks file and Element. This will clone the Element (without adding the entire scene as a reference. Optionally you can set the NewName property to rename the clone.

add remove SKNode 1

 

  • AddRandomElementFromFile  – value should be a .sks file with multiple Element nodes (only one will be chosen to show). These elements get added in their same locations as the sks file.

add remove SKNode 2

 

  • AddReferenceFromFile – value should a .sks file. Everything in the SKS file will be created and added.

add remove SKNode 3

 

  • Show – value can be blank to show the current node touched or the value can be the name of any Element, SKSpriteNode or SKReferenceNode to show. This changes it’s .hidden property to false. This will affect all nodes with that same name. You can change the String value to Array to add multiple name values.

add remove SKNode 4

 

  • ShowOrHide – like the Show property but it will show the node if it is hidden, or hide the node if it is showing.
  • Hide – Like the Show property, but it will hide the node.
  • Remove – value can be blank to remove the current node (if used as a touch event) or the value(s) can be the name of any node remove.

Technically this changes it’s name property to “removeNode“, then after physics are simulated that frame, anything with a .name property of “removeNode” is cleared out. This will also change the node’s physics body Category Mask to 0 so it no longer responses to interactions before it is removed

 

 

 

 




Know what an affiliate program is? You make money just by sharing links to our site! Win. Win.

Earn when you refer any buyer here! 30 day tracking. Commissions are 33%-50% and recur on subscription products!