In the Platform Games tvOS and iOS Starter Kit

Setting up a Platform

From the Object Library tab, drag in a new Color Sprite to the scene…

Name the sprite anything you want, and set a texture for it. Note, adding a texture is actually optional, as you can have invisible platforms.

Next go to the Physics Definition section and set the Body Type. You can choose any body type, but you’ll usually want Bounding Rectangle or Alpha. And normally, you’ll want Dynamic, Allows Rotation and Affected by Gravity toggled off.

Finally switch to the Custom Class tab, and set the Custom Class.

Platform Custom Classes

You have these options for your Custom Class…

  • Platform – a basic, non-moving platform. The physics body stays constant.
  • MovingPlatform – if you animate your platform using the Timeline, you’ll want to set this for the Custom Class. This will help keep your player on the platform as it moves.
  • OneWayPlatform – if you choose this option, the player can jump up through the platform. So the physics body is turned on and off depending on where the player is.
  • TwoWayPlatform – (Available in v1.70) Similar to the OneWayPlatform but if the player moves the virtual joystick / controller down while on the platform, they can fall through it.  Great for platforms that have poles/ladders through them.



Extending What Platforms Can Do

After your custom class is set, Platforms do not require any extra properties. So you do NOT have to note each platform in the LevelData.plist.

But if you want to include extra options for certain platforms you can. For example, the Retro-style Demo of the kit includes two platforms, one that rewards coins, and eventually breaks. And another which ricochets bullets.

Although there are many more platforms in the scene, these are the only two that required extra properties, so you’ll notice the Platforms dictionary only has two sub-dictionaries (the Key names match the names of the platforms in the scene).

Break/Coin Properties

  • Breakable – a Bool value, if set to YES, the platform will break when the player contacts it from directly underneath.
  • BreakAnimation – a String value that matches a Saved Action in the Actions.sks, most likely a texture animation that shows the platform breaking
  • BreakSound – a String value for the sound the platform will make when it breaks. Include the full name, like Thud.caf or Break.mp3
  • BumpAnimation – if the platform rewards coins, you can include this property. It is a String value that matches a Saved Action in the Actions.sks file. This could be a MoveBy action which makes the platform bump upward and backdown.
  • CoinImage – the image asset name of an coin (or other reward) to drop when the player contacts the platform from underneath. This can be combined with the Breakable option to reward a coin before breaking.
  • CoinAnimation – a String value that matches a Saved Action in the Actions.sks. This could be a texture animation that shows the coin spinning or animating in some way. Or it could be a MoveBy action which makes the coin float.
  • CoinAllowsRotation –  a Bool NO value means the coin is not will not rotate  (by default it will rotate)
  • CoinAffectedByGravity – a Bool NO value means the coin is not affected by gravity  (by default it is)
  • MaxCoins – a Number value for the max number of coins that will be rewarded. For example, if this is 3, the player could bump the platform 3 times and get 3 coins. If the platform is also breakable, on the third contact the platform would break.
  • CoinDelay – a Number value for a delay between the player contact and when the coin is dropped. Ideally you want a little delay like 0.2, so the coin has a chance to fall.
  • CoinOffset – a String value to offset where the coin appears in relation to the platform. This value is in {x,y} format. {0, 40} would not offset the coin on the x axis, but would push it up on the y axis by 40 points.
  • CoinValue – a Number value for how much score the player gets when they contact the coin.
  • CoinBumpSound – a String value for the sound the platform will make when it rewards a coin. Include the full name, like CoinBump.caf or CoinBump.mp3
  • CoinEmptySound – a String value for the sound the platform will make when it has no more coins to reward. Include the full name, like CoinEmpty.caf or CoinEmpty.mp3

Game-Enhancing Properties

  • RicochetBullet – a Bool value, when set to YES the platform will reverse the direction of bullets that hit it.
  • Animation – a String value that matches a Saved Action in the Actions.sks. This could be a texture animation, move action, etc. To use the next two properties that pause or unpause  the platform, you need to use this property. Note you can always include an animation for your Platform in the Scene Editor timeline, but doing so, and using the properties below causes some hiccups when pausing the action.
  • PauseWithPlayerContact – a Bool YES value will make the Platform pause it’s Animation actions. So for example, if the platform is moving, it will stop moving on contact.
  • UnPauseWithPlayerContact – a Bool YES value will make the Platform unpause it’s Animation actions. In other words, the exact opposite of the previous property (so don’t use both). For example, if the platform is not moving, and the player jumps on it, then it would begin moving.
  • RotateWithPlayerContact – a Bool YES value which makes the platform begin to rotate on either side the player is on. So it begins a balancing act for the player to stay on. To best use this property, in your Scene Editor be sure to toggle on Pinned under the Physics options. Doing so will make it so the weight of the player doesn’t push down the platform. Also you can try adjusting the Mass to make it so the Platform is more or less affected by the weight of the player when rotating.
  • GravityWithPlayerContact –  a Bool YES value which makes the platform affected by gravity if the player is on it. You probably want to set the ResetPlatformTime in the general settings of the level to something other than 0 if you use this property.