// Use this for initialization void Start() { agent = gameObject.GetComponent <Seeker>(); controller = gameObject.GetComponent <CharacterController>(); spriteManager = gameObject.GetComponent <SpriteManager>() as SpriteManager; evilSprite = spriteManager.AddSprite(gameObject, 2.0f, 2.0f, spriteManager.PixelSpaceToUVSpace(256, 256), spriteManager.PixelSpaceToUVSpace(50, 50), false); evilSprite.SetAnimCompleteDelegate(OnAnimateComplete); Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace(50, 50); //Idle animation UVAnimation idleAnimation = new UVAnimation(); Vector2 idleStartPosUV = spriteManager.PixelCoordToUVCoord(0, 50); idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, 3, 2, 6, 15); idleAnimation.loopCycles = -1; idleAnimation.name = "idle"; evilSprite.AddAnimation(idleAnimation); evilSprite.PlayAnim("idle"); gameObject.transform.position = 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 override void AddMoveAnimation() { moveAnimation = new UVAnimation(); Vector2 startPosUV = sm.PixelCoordToUVCoord(0, 84); Vector2 spriteSize = sm.PixelSpaceToUVSpace(88, 84); moveAnimation.BuildUVAnim(startPosUV, spriteSize, 8, 2, 8, animationFps); moveAnimation.name = MOVE; moveAnimation.loopCycles = -1; sprite.AddAnimation(moveAnimation); }
private void createSprite() { enemySprite = spriteManager.AddSprite(gameObject, InGameSize.x, InGameSize.y, spriteManager.PixelSpaceToUVSpace((int)TextureSize.x, (int)TextureSize.y), spriteManager.PixelSpaceToUVSpace((int)FrameSize.x, (int)FrameSize.y), false); enemySprite.SetAnimCompleteDelegate(OnAnimateComplete); Vector2 spriteSize = spriteManager.PixelSpaceToUVSpace((int)FrameSize.x, (int)FrameSize.y); //Idle animation UVAnimation idleAnimation = new UVAnimation(); Vector2 idleStartPosUV = spriteManager.PixelCoordToUVCoord((int)idleStartPos.x, (int)idleStartPos.y); idleAnimation.BuildUVAnim(idleStartPosUV, spriteSize, (int)idleSpriteSheetPos.x, (int)idleSpriteSheetPos.y, (int)idleAnimLength, fps); idleAnimation.loopCycles = -1; idleAnimation.name = "idle"; enemySprite.AddAnimation(idleAnimation); //Walk animation UVAnimation walkAnimation = new UVAnimation(); Vector2 walkStartPosUV = spriteManager.PixelCoordToUVCoord((int)walkStartPos.x, (int)walkStartPos.y); walkAnimation.BuildUVAnim(walkStartPosUV, spriteSize, (int)walkSpriteSheetPos.x, (int)walkSpriteSheetPos.y, (int)walkAnimLength, fps); walkAnimation.loopCycles = -1; walkAnimation.name = "walk"; enemySprite.AddAnimation(walkAnimation); //Shoot animation UVAnimation shootAnimation = new UVAnimation(); Vector2 shootStartPosUV = spriteManager.PixelCoordToUVCoord((int)shootStartPos.x, (int)shootStartPos.y); shootAnimation.BuildUVAnim(shootStartPosUV, spriteSize, (int)shootSpriteSheetPos.x, (int)shootSpriteSheetPos.y, (int)shootAnimLength, fps); shootAnimation.loopCycles = 0; shootAnimation.name = "shoot"; enemySprite.AddAnimation(shootAnimation); //Die animation UVAnimation dieAnimation = new UVAnimation(); Vector2 dieStartPosUV = spriteManager.PixelCoordToUVCoord((int)dieStartPos.x, (int)dieStartPos.y); dieAnimation.BuildUVAnim(dieStartPosUV, spriteSize, (int)dieSpriteSheetPos.x, (int)dieSpriteSheetPos.y, (int)dieAnimLength, fps); dieAnimation.loopCycles = 0; dieAnimation.name = "die"; enemySprite.AddAnimation(dieAnimation); gameObject.transform.position = startPos; }
void CreateSprites() { // Create sprites for three of the balls: for (int i = 0; i < 3; ++i) { Sprite s = spriteMan.AddSprite((GameObject)balls[i], // The game object to associate the sprite to 1f, // The width of the sprite 1f, // The height of the sprite 251, // Left pixel 509, // Bottom pixel 256, // Width in pixels 256, // Height in pixels false); // Billboarded? ballSprites.Add(s); } // Create billboarded sprites for the other three balls: for (int i = 3; i < 6; ++i) { Sprite s = spriteMan.AddSprite((GameObject)balls[i], // The game object to associate the sprite to 1f, // The width of the sprite 1f, // The height of the sprite 251, // Left pixel 509, // Bottom pixel 256, // Width in pixels 256, // Height in pixels true); // Billboarded? ballBillboards.Add(s); } // Create sprites for three of the cans: for (int i = 0; i < 3; ++i) { Sprite s = spriteMan.AddSprite((GameObject)cans[i], // The game object to associate the sprite to 0.524f, // The width of the sprite 1f, // The height of the sprite 3, // Left pixel 253, // Bottom pixel 130, // Width in pixels 256, // Height in pixels false); // Billboarded? canSprites.Add(s); } // Create billboarded sprites for the other three cans: for (int i = 3; i < 6; ++i) { Sprite s = spriteMan.AddSprite((GameObject)cans[i], // The game object to associate the sprite to 0.524f, // The width of the sprite 1f, // The height of the sprite 3, // Left pixel 253, // Bottom pixel 130, // Width in pixels 256, // Height in pixels true); // Billboarded? canBillboards.Add(s); } // Save the actual UVs of the two soda can images (lower-left corner): drPepperUV = spriteMan.PixelCoordToUVCoord(3, 253); cokeUV = spriteMan.PixelCoordToUVCoord(140, 253); sodaCanSize = spriteMan.PixelSpaceToUVSpace(130, 256); }
void Start() { sm = GameObject.Find("_SpriteManager").GetComponent <LinkedSpriteManager>(); sprite = sm.AddSprite(this.gameObject, 1.5f, 1.5f, sm.PixelCoordToUVCoord(8 * 96, 288), sm.PixelSpaceToUVSpace(96, 96), Vector3.zero, false); }