帧动画处理脚本


		if(isDeath){
				timer+=Time.deltaTime;// 0
				int frameIndex = (int)(timer/(1f/explosionAnimationFrame));
				if(frameIndex>=explosionSprites.Length){
					//destroy
					Destroy(this.gameObject);
				}else{
					render.sprite= explosionSprites[frameIndex];
				}
		}else{
			if(type==EnemyType.middleEnemy||type==EnemyType.bigEnemy){
				if(hitTimer>=0){
					hitTimer-=Time.deltaTime;


					int frameIndex = (int)((resetHitTime-hitTimer)/(1f/explosionAnimationFrame));
					frameIndex%=2;
					render.sprite= hitSprites[frameIndex];
				}
			}

if(animation){
			timer+=Time.deltaTime;// 1f/frameCountPersconds
			int frameIndex = (int)(timer/(1f/frameCountPersconds));
			int frame = frameIndex%2;
			spriteRender.sprite = sprites[frame];
		}




你可能感兴趣的:(GUI,unity3d)