-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpriteParticle.cs
39 lines (29 loc) · 1.17 KB
/
SpriteParticle.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using UnityEngine;
using System.Collections;
public class SpriteParticle : LookAtSprite {
SpriteManager spriteManager;
Sprite particleSprite;
public Vector3 startPos;
// Use this for initialization
void Start () {
spriteManager = gameObject.GetComponent<SpriteManager>() as SpriteManager;
particleSprite = spriteManager.AddSprite(gameObject, 1.0f, 1.0f, spriteManager.PixelSpaceToUVSpace(128,128), spriteManager.PixelSpaceToUVSpace(30, 30), false);
particleSprite.SetAnimCompleteDelegate(OnAnimateComplete);
Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(30, 30);
//Idle animation
UVAnimation idleAnimation = new UVAnimation();
Vector2 idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 30);
idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 5, 15);
idleAnimation.loopCycles = 0;
idleAnimation.name = "idle";
particleSprite.AddAnimation(idleAnimation);
particleSprite.PlayAnim("idle");
transform.position = new Vector3(startPos.x, startPos.y, startPos.z);
}
public void OnAnimateComplete(string name) {
Destroy(gameObject);
}
void Update() {
LookAtPlayer();
}
}