diff --git a/Assets/Fungus/Animation.meta b/Assets/Fungus/Animation.meta new file mode 100644 index 00000000..6a585646 --- /dev/null +++ b/Assets/Fungus/Animation.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: 623a31d1ed64f48c18a2941fb2e6bb4b +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Fungus/Sprite/Commands/SetAnimBool.cs b/Assets/Fungus/Animation/SetAnimBool.cs similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimBool.cs rename to Assets/Fungus/Animation/SetAnimBool.cs diff --git a/Assets/Fungus/Sprite/Commands/SetAnimBool.cs.meta b/Assets/Fungus/Animation/SetAnimBool.cs.meta similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimBool.cs.meta rename to Assets/Fungus/Animation/SetAnimBool.cs.meta diff --git a/Assets/Fungus/Sprite/Commands/SetAnimFloat.cs b/Assets/Fungus/Animation/SetAnimFloat.cs similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimFloat.cs rename to Assets/Fungus/Animation/SetAnimFloat.cs diff --git a/Assets/Fungus/Sprite/Commands/SetAnimFloat.cs.meta b/Assets/Fungus/Animation/SetAnimFloat.cs.meta similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimFloat.cs.meta rename to Assets/Fungus/Animation/SetAnimFloat.cs.meta diff --git a/Assets/Fungus/Sprite/Commands/SetAnimInteger.cs b/Assets/Fungus/Animation/SetAnimInteger.cs similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimInteger.cs rename to Assets/Fungus/Animation/SetAnimInteger.cs diff --git a/Assets/Fungus/Sprite/Commands/SetAnimInteger.cs.meta b/Assets/Fungus/Animation/SetAnimInteger.cs.meta similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimInteger.cs.meta rename to Assets/Fungus/Animation/SetAnimInteger.cs.meta diff --git a/Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs b/Assets/Fungus/Animation/SetAnimTrigger.cs similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs rename to Assets/Fungus/Animation/SetAnimTrigger.cs diff --git a/Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs.meta b/Assets/Fungus/Animation/SetAnimTrigger.cs.meta similarity index 100% rename from Assets/Fungus/Sprite/Commands/SetAnimTrigger.cs.meta rename to Assets/Fungus/Animation/SetAnimTrigger.cs.meta diff --git a/Assets/Fungus/Sprite/Prefabs/Button.prefab b/Assets/Fungus/Sprite/Prefabs/Button.prefab deleted file mode 100644 index f830536d..00000000 Binary files a/Assets/Fungus/Sprite/Prefabs/Button.prefab and /dev/null differ diff --git a/Assets/Fungus/Sprite/Prefabs/Button.prefab.meta b/Assets/Fungus/Sprite/Prefabs/Button.prefab.meta deleted file mode 100644 index c6a9f627..00000000 --- a/Assets/Fungus/Sprite/Prefabs/Button.prefab.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: 2830c354320dd41fb8c7fe61f592942c -NativeFormatImporter: - userData: diff --git a/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab b/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab deleted file mode 100644 index 4d49a346..00000000 Binary files a/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab and /dev/null differ diff --git a/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab.meta b/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab.meta deleted file mode 100644 index 4dedd3d2..00000000 --- a/Assets/Fungus/Sprite/Prefabs/GUIButton.prefab.meta +++ /dev/null @@ -1,4 +0,0 @@ -fileFormatVersion: 2 -guid: a55e55be9295f4b9db04d66b1f66612c -NativeFormatImporter: - userData: diff --git a/Assets/Fungus/Sprite/Scripts/AnimationListener.cs b/Assets/Fungus/Sprite/Scripts/AnimationListener.cs deleted file mode 100644 index c101bdf3..00000000 --- a/Assets/Fungus/Sprite/Scripts/AnimationListener.cs +++ /dev/null @@ -1,25 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace Fungus -{ - /** - * Listener component to handle animation events. - * Usage: - * 1. Attach this script to the animated sprite that you want to listen to for events. - * 2. Add an event on the animation timeline - * 3. Edit the event and choose the 'CallRoomMethod' function - * 4. In the string parameters box, enter the name of the method to call in the active Room's script. - */ - public class AnimationListener : MonoBehaviour - { - /** - * Handler method for animation events. - * The string event parameter is used to call a named method on the active room class - */ - void CallRoomMethod(string methodName) - { - // TODO: Execute a FungusScript sequence - } - } -} \ No newline at end of file diff --git a/Assets/Fungus/Sprite/Scripts/AnimationListener.cs.meta b/Assets/Fungus/Sprite/Scripts/AnimationListener.cs.meta deleted file mode 100644 index c3d971ee..00000000 --- a/Assets/Fungus/Sprite/Scripts/AnimationListener.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6876254e624e04c9c9e4d2d9edb2901c -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/Sprite/Scripts/Parallax.cs b/Assets/Fungus/Sprite/Scripts/Parallax.cs index 64f38a5f..7cd13701 100644 --- a/Assets/Fungus/Sprite/Scripts/Parallax.cs +++ b/Assets/Fungus/Sprite/Scripts/Parallax.cs @@ -5,28 +5,22 @@ namespace Fungus { /** * Attach this component to a sprite object to apply a simple parallax scrolling effect. - * The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the parent Room. - * The scale parallax is calculated based on the ratio of the camera size to the size of the Room. This gives a 'dolly zoom' effect. - * Accelerometer based parallax may also be applied on devices that support it. + * The horizontal and vertical parallax offset is calculated based on the distance from the camera to the position of the background sprite. + * The scale parallax is calculated based on the ratio of the camera size to the size of the background sprite. This gives a 'dolly zoom' effect. + * Accelerometer based parallax is also applied on devices that support it. */ public class Parallax : MonoBehaviour { /** - * Scale factor for calculating the parallax offset. - */ - public Vector2 parallaxScale = new Vector2(0.25f, 0f); - - /** - * Scale factor when camera is zoomed out to show the full Room. - * This will typically be set to 1 to show the sprite at normal size. + * The background sprite which this sprite is layered on top of. + * The position of this sprite is used to calculate the parallax offset. */ - public float zoomedOutScale = 1f; + public SpriteRenderer backgroundSprite; /** - * Scale factor when camera is fully zoomed in on Room. - * Setting this to a value greater than 1 will give a 'dolly zoom' effect when zooming in. + * Scale factor for calculating the parallax offset. */ - public float zoomedInScale = 1f; + public Vector2 parallaxScale = new Vector2(0.25f, 0f); /** * Scale factor for calculating parallax offset based on device accelerometer tilt angle. @@ -35,7 +29,6 @@ namespace Fungus public float accelerometerScale = 0.5f; Vector3 startPosition; - // Vector3 startScale; Vector3 acceleration; Vector3 velocity; @@ -44,20 +37,33 @@ namespace Fungus { // Store the starting position and scale of the sprite object startPosition = transform.position; - // startScale = transform.localScale; + + // Default to using parent sprite as background + if (backgroundSprite == null) + { + backgroundSprite = gameObject.GetComponentInParent(); + } } void Update () { + if (backgroundSprite == null) + { + return; + } + Vector3 translation = Vector3.zero; - // Apply parallax translation based on camera position relative to Room + // Apply parallax translation based on camera position relative to background sprite { - Vector3 a = startPosition; + Vector3 a = backgroundSprite.bounds.center; Vector3 b = Camera.main.transform.position; translation = (a - b); translation.x *= parallaxScale.x; translation.y *= parallaxScale.y; + translation.z = 0; + + // TODO: Limit parallax offset to just outside the bounds of the background sprite } // Apply parallax translation based on device accelerometer @@ -72,14 +78,6 @@ namespace Fungus } transform.position = startPosition + translation; - - // Set new scale for sprite - /* - float roomSize = parentRoom.renderer.bounds.extents.y; - float t = Camera.main.orthographicSize / roomSize ; - float scale = Mathf.Lerp (zoomedInScale, zoomedOutScale, t); - transform.localScale = startScale * scale; - */ } } } diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 1d5fe2c8..a1ea153a 100644 Binary files a/Assets/Shuttle/ShuttleGame.unity and b/Assets/Shuttle/ShuttleGame.unity differ