1
Support / Re: Creating a parallax background with orthographic view.
« on: August 13, 2013, 10:30:35 am »
Cheers!
I sent in my request.
I sent in my request.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
gameObject.sprite.scale = new Vector3(-1,gameObject.transform.position.y, 0); using UnityEngine;
using System.Collections;
public class Animations : MonoBehaviour {
//private bool walking = false;
private tk2dSpriteAnimator anim;
// Use this for initialization
void Start () {
anim = GetComponent<tk2dSpriteAnimator>();
}
//Go back to idle when nothing is pressed.
void HitCompleteDelegate(tk2dSpriteAnimator sprite, tk2dSpriteAnimationClip clip)
{
anim.Play ("idle");
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.D))
{
anim.Play("walk");
anim.AnimationCompleted = HitCompleteDelegate;
}
if (Input.GetKey (KeyCode.A))
{
anim.Play("walk"); //I want the sprite play walk flipped. I tried adding sprite.scale *= (-1,1,1); here, but did not work.
anim.AnimationCompleted = HitCompleteDelegate;
}
}
}