Physics Events – Story Tellers iOS Starter Kit Documentation

  • ReverseGravity – will reverse whatever the gravity currently is in the scene. No value is needed. If the gravity was {2, 4} it will be {-2, -4}

physics event 1

  • ReverseGravityOnX – will reverse whatever the gravity currently is, but only on the x axis
  • ReverseGravityOnY – will reverse whatever the gravity currently is, but only on the y axis
  • GravityOn – the value will be the Element to enable gravity. The Element should already have a physics body set.

physics event 2

  • GravityOff –   the value will be the Element to no longer be affected by gravity. The Element should already have a physics body set.
  • GravityOnOrOff –   the value will be the Element to toggle the effect of gravity on them
  • DynamicOn – the value will be the Element to toggle the physics dynamic property on. Once on, it will be included in the scene’s physics simulations. The Element should already have a physics body set.
  • DynamicOff – the value will be the Element to toggle the physics dynamic property off. The Element will be excluded from physics simulations but still retain it’s collision body. The Element should already have a physics body set.
  • DynamicOnOrOff – will toggle the dynamic property on or off.
  • RotationOn – will allow the physics body to rotate.

physics event 3

  • RotationOff – will disable the physics body from rotating.
  • RotationOnOrOff  – will toggle whether or not the physics body is allowed to rotate.
  • SetGravity – sets the world’s gravity in  {x, y} format. In the example below, gravity is -2 on the y axis and gravity is 0 on the x axis (so no pull on x)

physics event 4

  • ForceVector – when used as a TouchEvent set a String value for the force to apply to the Element touched. The vector is defined in  {x, y} format.  This can also be a Dictionary where each key name is the Element and the key value is the vector (see the image below).

physics event 5

  • ImpulseVector – when used as a TouchEvent set a String value, for the vector impulse to apply to the Element touched. The vector is defined in  {x, y} format.  This can also be a Dictionary where each key name is the Element and the key value is the vector (see the image above).
  • StopPhysics – You might notice when trying to stop a physics body from moving (for example, by disabling gravity or rotation) it still has “something” pushing it around. This is probably due to leftover forces and angular velocities still being applied. If that’s the case, use this property.

physics event 6


Detecting Collisions with Specific Objects

To read more about this visit the general properties page for Elements. 

 

 

 

 

 

 

If you stumbled onto this article, it is part of our documentation for the Story Tellers iOS Starter Kit 2. The kit enables you to make children’s book apps and games without writing any code! But it is Swift 2 based and compatible with iOS9 (or higher) and Xcode 7 (or higher), so kit buyers can even extend the functionality to fit their needs further. Some of what we cover in the kit documentation may apply to Xcode in general, so this article could be worth a read even if you aren’t a user. You can purchase Lifetime Updates the kit here, or subscribe Yearly to CartoonSmart and get the latest version, plus access to all of our other kits / tutorials.

We’ve also created an iBook to document the very latest properties in the kit, so be sure to download that as well.