Hello Guest

Show Posts

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.


Messages - mike2d

Pages: 1 ... 3 4 [5]
61
Support / Re: delegate
« on: June 25, 2012, 10:47:55 am »
wow,

so you have 2 objects "animation" & "animatedSprite" ? how do you declare them ?

by the way, there is my code with the added line from yours (
Code: [Select]
if (animation.IsPlaying()...) but no animation fires... :

Code: [Select]
void Start ()
{
anim = GetComponent<tk2dAnimatedSprite> ();
}

void Update ()
{

if (Input.GetKeyDown ("space")) { // jump
rigidbody.AddRelativeForce (transform.up * jumpSpeed, ForceMode.Impulse);
}

// if not hiding
if (!hiding) {

movement = Input.GetAxis ("Horizontal") * moveSpeed; 
movement *= Time.deltaTime; 
transform.Translate (movement, 0.0f, 0.0f);

if (Input.GetKeyDown (KeyCode.S)) { // hide
anim.Play ("hide");
hiding = true;

} else if (Input.GetKeyDown (KeyCode.D)) { // walk right
if (anim.isPlaying () && anim.CurrentClip.name != "walkleft")
anim.Play ("walk");
if (!goingRight)
anim.FlipX ();
goingRight = true;

} else if (Input.GetKeyDown (KeyCode.A)) { // walk left
if (anim.isPlaying () && anim.CurrentClip.name == "walkleft")
anim.Play ("walk");
if (goingRight)
anim.FlipX ();
goingRight = false;

} else {
anim.Play ("idle");
}

} else {

// unhide
if (Input.GetKeyDown (KeyCode.W)) {
anim.Play ("unhide");
hiding = false;
}
}
}

62
Support / Re: delegate
« on: June 25, 2012, 10:19:30 am »
ok so what's the solution to stop an animation in the middle because i released a key and set the character back to it's idle position or to keep it playing when the animation cycle is finished because i'm still pressing the key ?

63
Support / delegate
« on: June 22, 2012, 08:43:38 am »
hi,

very new to 2d toolkit and 2d animation in general :)

i'm experiencing some strange behavior with my sprite animations.

it's a simple sprite (a character) who walks right and left. but when i stop pressing "A" or "D" button, the animation stops in a strange position and the object is offset upward...

I saw there was an "animation complete delegate" function. actually, i don't understand it's purpose and wish someone could explain it to me and maybe give some tutorial examples (i've seen the example given by 2D Toolkit but isn't enough to understand).

Pages: 1 ... 3 4 [5]