本文整理汇总了C#中Sprite.SetFrame方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.SetFrame方法的具体用法?C# Sprite.SetFrame怎么用?C# Sprite.SetFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.SetFrame方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
//.........这里部分代码省略.........
if(iRock > 75)
{
_Sprite.AddFrame("Rock1F1.png");
_Sprite.AddFrame("Rock1F2.png");
_Sprite.AddFrame("Rock1F3.png");
_Sprite.AddFrame("Rock1F4.png");
}
else if(iRock > 50)
{
_Sprite.AddFrame("Rock2F1.png");
_Sprite.AddFrame("Rock2F2.png");
_Sprite.AddFrame("Rock2F3.png");
_Sprite.AddFrame("Rock2F4.png");
}
else if(iRock > 25)
{
_Sprite.AddFrame("Rock3F1.png");
_Sprite.AddFrame("Rock3F2.png");
_Sprite.AddFrame("Rock3F3.png");
_Sprite.AddFrame("Rock3F4.png");
}
else
{
_Sprite.AddFrame("Rock4F1.png");
_Sprite.AddFrame("Rock4F2.png");
_Sprite.AddFrame("Rock4F3.png");
_Sprite.AddFrame("Rock4F4.png");
}
_Sprite._Width = 4.1f;
_Sprite._Height = 4.1f;
_Sprite._Animate = false;
_Sprite._Y = 0.0f;
_Sprite.SetFrame(0);
_Radius = 1.1f;
_Speed = 10.0f + Random.Range(0.0f,5.0f);
_Value = 1;
_Width = 3.0f * 0.5f;
_Height = (3.0f * 0.5f) * Director._Instance._Aspect;
_AABBCollision = true;
_HitPoints = 4;
_CurrentFrame = 0;
_FrameAdvanceOnHit = true;
AddToDelegates();
break;
case eAIType.AITYPE_BULLET:
_Sprite = Sprite.Spawn(1);
_Sprite.AddFrame("EnemyBullet.png");
_Sprite._Width = 0.8f;
_Sprite._Height = 0.8f;
_Sprite._Animate = false;
_Sprite._Y = 0.15f;
_Radius = 0.1f;
_Speed = 8.0f;
_Value = 1;
_AABBCollision = false;
_HitPoints = 1;
_Width = 0.5f * 0.5f;
_Height = (0.5f * 0.5f) * Director._Instance._Aspect;
_FrameAdvanceOnHit = false;
AddToDelegates();
break;
case eAIType.AITYPE_POWERUP:
_Sprite = Sprite.Spawn(1);
示例2: Update
void Update()
{
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite._Width = _Width;
_Sprite._Height = _Height;
_Sprite._Animate = false;
_Sprite.AddFrame(_UpImage);
_Sprite.AddFrame(_DownImage);
_Sprite.AddFrame(_OverImage);
_Sprite.AddFrame(_LockUp);
_Sprite.AddFrame(_LockDown);
_Sprite._X = 10000.0f;
_Sprite._Z = 10000.0f;
_Sprite._Y = _Depth;
if(_Locked)
{
_Sprite.SetFrame(2);
}
}
switch(_Ease)
{
case eButtonEase.BUTTON_EASE_IN:
_Time += _Speed * Time.deltaTime;
if(_Time > 1.0f)
{
_Time = 1.0f;
_C = _B;
_Ease = eButtonEase.BUTTON_EASE_NONE;
if(_Shake)
{
Director._Instance.ShakeCamera(_ShakeIntensity,_ShakeTime);
}
}
float fRealTime = 1.0f - _Time;
_C = _B + (_A - _B) * (fRealTime * fRealTime);
break;
case eButtonEase.BUTTON_EASE_OUT:
_Time -= _Speed * Time.deltaTime;
if(_Time < 0.0f)
{
_Time = 0.0f;
_C = _A;
_Ease = eButtonEase.BUTTON_EASE_KILL;
}
_C = _A + (_B - _A) * (_Time * _Time);
break;
case eButtonEase.BUTTON_EASE_KILL:
this.active = false;
_Sprite._Alive = false;
break;
}
this.transform.position = _C;
_Sprite._X = _C.x;
_Sprite._Z = _C.z;
if(Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 100))
{
if(hit.transform.gameObject.name == this.name)
{
_IsButtonDown = true;
if(_Locked)
{
_Sprite.SetFrame(3);
}
else
{
_Sprite.SetFrame(1);
}
}
}
}
if(Input.GetMouseButtonUp(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit, 100))
{
if(hit.transform.gameObject.name == this.name)
//.........这里部分代码省略.........