本文整理汇总了C#中Sprite.AddFrame方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.AddFrame方法的具体用法?C# Sprite.AddFrame怎么用?C# Sprite.AddFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.AddFrame方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebugDrawSpline
public void DebugDrawSpline()
{
_WayPoints.DebugDrawSpline(_OffsetX,_OffsetZ);
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite.AddFrame("Enemy1F1.png");
_Sprite.AddFrame("Enemy1F2.png");
_Sprite.AddFrame("Enemy1F3.png");
_Sprite.AddFrame("Enemy1F4.png");
_Sprite.AddFrame("Enemy1F3.png");
_Sprite.AddFrame("Enemy1F2.png");
_Sprite._Width = 1.2f;
_Sprite._Height = 1.2f;
_Sprite._Animate = true;
_Sprite._Y = 0.1f;
}
_DebugT += _Speed * Time.deltaTime;
if(_DebugT >= 1.0f)
{
_DebugT = 0.0f;
}
Vector3 vPos = _WayPoints.Spline(_DebugT);
_Sprite._X = vPos.x;
_Sprite._Z = vPos.z;
// Draw a circle to represent the speed
Vector3 vA = Vector3.zero;
Vector3 vB = Vector3.zero;
Vector3 vColour = new Vector3(1.0f,1.0f,0.0f);
float fAngle = 0.0f;
float fStep = 360.0f / 30.0f;
vA.x = (Mathf.Sin(fAngle * Mathf.Deg2Rad) * (_Speed * 2.0f)) + _OffsetX;
vA.z = (Mathf.Cos(fAngle * Mathf.Deg2Rad) * (_Speed * 2.0f)) + _OffsetZ;
fAngle += fStep;
for(int i = 0; i < 30; ++i)
{
vB.x = (Mathf.Sin(fAngle * Mathf.Deg2Rad) * (_Speed * 2.0f)) + _OffsetX;
vB.z = (Mathf.Cos(fAngle * Mathf.Deg2Rad) * (_Speed * 2.0f)) + _OffsetZ;
Director._Instance.AddLine(vColour,vA,vB);
fAngle += fStep;
vA = vB;
}
}
示例2: Tile
public Tile(int id, Sprite sprite)
{
Id = id;
Sprite = sprite;
if (Sprite.Count == 0) Sprite.AddFrame();
Properties = TileProperties.Default;
}
示例3: Update
// Update is called once per frame
void Update()
{
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite._Width = _Transform.localScale.x;
_Sprite._Height = _Transform.localScale.y;
_Sprite._Animate = false;
_Sprite.AddFrame(_Name);
_Sprite._X = 1000.0f;
_Sprite._Z = 1000.0f;
_Sprite._Y = 0.1f;
}
_Sprite._X = _Transform.position.x;
_Sprite._Z = _Transform.position.z;
_Sprite._Width = _Transform.localScale.x;
_Sprite._Height = _Transform.localScale.y;
}
示例4: Update
void Update()
{
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite._Width = _Width;
_Sprite._Height = _Height;
_Sprite._Animate = false;
_Sprite.AddFrame(_Image);
_Sprite._X = 1000.0f;
_Sprite._Z = 1000.0f;
}
switch(_Ease)
{
case eTitleEase.TITLE_EASE_IN:
_Time += Time.deltaTime;
if(_Time > 1.0f)
{
_Time = 1.0f;
_C = _B;
_Ease = eTitleEase.TITLE_EASE_NONE;
}
float fRealTime = 1.0f - _Time;
_C = _B + (_A - _B) * (fRealTime * fRealTime);
break;
case eTitleEase.TITLE_EASE_OUT:
_Time -= Time.deltaTime;
if(_Time < 0.0f)
{
_Time = 0.0f;
_C = _A;
_Ease = eTitleEase.TITLE_EASE_KILL;
}
_C = _A + (_B - _A) * (_Time * _Time);
break;
case eTitleEase.TITLE_EASE_KILL:
this.active = false;
_Sprite._Alive = false;
break;
}
this.transform.position = _C;
_Sprite._X = _C.x;
_Sprite._Z = _C.z;
}
示例5: Update
// Update is called once per frame
void Update()
{
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite._Width = _Transform.localScale.x;
_Sprite._Height = _Transform.localScale.y;
_Sprite._Animate = false;
_Sprite.AddFrame("V10.png");
_Sprite.AddFrame("V9.png");
_Sprite.AddFrame("V8.png");
_Sprite.AddFrame("V7.png");
_Sprite.AddFrame("V6.png");
_Sprite.AddFrame("V5.png");
_Sprite.AddFrame("V4.png");
_Sprite.AddFrame("V3.png");
_Sprite.AddFrame("V2.png");
_Sprite.AddFrame("V1.png");
_Sprite.AddFrame("V0.png");
_Sprite._X = 1000.0f;
_Sprite._Z = 1000.0f;
_Sprite._Y = 0.1f;
}
_Sprite._X = _Transform.position.x;
_Sprite._Z = _Transform.position.z;
_Sprite._Width = _Transform.localScale.x;
_Sprite._Height = _Transform.localScale.y;
if(Director._Instance._SFXVolume > 0.9f)
{
_Sprite.SetFrame(0);
}
else if(Director._Instance._SFXVolume > 0.8f)
{
_Sprite.SetFrame(1);
}
else if(Director._Instance._SFXVolume > 0.7f)
{
_Sprite.SetFrame(2);
}
else if(Director._Instance._SFXVolume > 0.6f)
{
_Sprite.SetFrame(3);
}
else if(Director._Instance._SFXVolume > 0.5f)
{
_Sprite.SetFrame(4);
}
else if(Director._Instance._SFXVolume > 0.4f)
{
_Sprite.SetFrame(5);
}
else if(Director._Instance._SFXVolume > 0.3f)
{
_Sprite.SetFrame(6);
}
else if(Director._Instance._SFXVolume > 0.2f)
{
_Sprite.SetFrame(7);
}
else if(Director._Instance._SFXVolume > 0.1f)
{
_Sprite.SetFrame(8);
}
else if(Director._Instance._SFXVolume > 0.0f)
{
_Sprite.SetFrame(9);
}
else
{
_Sprite.SetFrame(10);
}
}
示例6: Update
void Update()
{
_Delay -= Time.deltaTime;
if(_Delay > 0.0f)
{
return;
}
_Delay = 0.0f;
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
_Sprite._Width = _SA.x;
_Sprite._Height = _SA.y;
_Sprite._Animate = false;
_Sprite.AddFrame(_Image);
_Sprite._X = 1000.0f;
_Sprite._Z = 1000.0f;
_Sprite._Y = _Depth;
}
switch(_Ease)
{
case eIMAGEEase.IMAGE_EASE_IN:
_Time += Time.deltaTime;
if(_Time > 1.0f)
{
_Time = 1.0f;
_C = _B;
_Ease = eIMAGEEase.IMAGE_EASE_NONE;
if(_FireEventOnFinishTransitionIn)
{
Director._Instance.FireEvent(_Event);
}
}
float fRealTime = 1.0f - _Time;
_C = _B + (_A - _B) * (fRealTime * fRealTime);
_SC = _SB + (_SA - _SB) * (fRealTime * fRealTime);
_Alpha = _BAlpha + (_AAlpha - _BAlpha) * (fRealTime * fRealTime);
break;
case eIMAGEEase.IMAGE_EASE_OUT:
_Time -= Time.deltaTime;
if(_Time < 0.0f)
{
_Time = 0.0f;
_C = _A;
_Ease = eIMAGEEase.IMAGE_EASE_KILL;
}
_C = _A + (_B - _A) * (_Time * _Time);
_SC = _SA + (_SB - _SA) * (_Time * _Time);
_Alpha = _AAlpha + (_BAlpha - _AAlpha) * (_Time * _Time);
break;
case eIMAGEEase.IMAGE_EASE_KILL:
this.active = false;
_Sprite._Alive = false;
Sprite.Kill(_Sprite);
_Sprite = null;
break;
}
this.transform.position = _C;
if(_Sprite != null)
{
_Sprite._X = _C.x;
_Sprite._Z = _C.z;
_Sprite._Width = _SC.x;
_Sprite._Height = _SC.y;
_Sprite._Alpha = _Alpha;
}
}
示例7: Start
//.........这里部分代码省略.........
pName.AddCompound("SFXNameContainer");
pName.AddCompound("NameContainer");
_Screens.Add("NAME",pName);
ScreenContainer pNewVersion = new ScreenContainer();
pNewVersion.AddButton("GoGetButton");
pNewVersion.AddButton("GoGetBackButton");
pNewVersion.AddUIGO("NewVersion");
_Screens.Add("NEW_VERSION",pNewVersion);
ScreenContainer pCompany = new ScreenContainer();
pCompany.AddUIGO("Company");
_Screens.Add("COMPANY",pCompany);
_Number = new Number();
_Number._Z = 10.0f;
_Number.Disable();
// Setup the initial game state
//_CurrentState = eGameState.GAMESTATE_SETUP_COMPANY;
_CurrentState = eGameState.GAMESTATE_SETUP_TITLE;
_Camera = GetComponent<Camera>();
// Disable components to start
_Player.Disable();
_Samples = new Dictionary<string,AudioClip>();
_SamplesTimeStamp = new Dictionary<string, float>();
_SamplePlayAlways = new Dictionary<string, bool>();
_AudioSource = this.GetComponent<AudioSource>();
// Add samples
AddSample("ALIEN_SHOT","SFX/Enemy");
AddSample("PLAYER_SHOT","SFX/PlayerShot2");
AddSample("EXPLOSION","SFX/Explosion");
AddSample("COIN","SFX/Coin");
AddSample("POWERUP","SFX/PowerUp");
AddSample("PLAYERDEATH","SFX/PlayerDeath",true);
AddSample("RAPIDFIRE","SFX/RapidFire",true);
AddSample("GAMEON","SFX/GameOn",true);
AddSample("WIPEOUT","SFX/WipeOut",true);
AddSample("CLICK","SFX/Click",true);
AddSample("PRESS","SFX/Press",true);
AddSample("THREEWAY","SFX/ThreeWay",true);
AddSample("MAGNET","SFX/Magnatism",true);
// Create lives sprites
_LivesSprites = new List<Sprite>();
float fLX = Ground._Instance._HigherX + 2.0f;
float fLZ = Ground._Instance._LowerZ - 2.0f;
for(int i = 0; i < 20; ++i)
{
Sprite pSprite = Sprite.Spawn(1);
pSprite.AddFrame("Life.png");
pSprite._Width = 0.5f;
pSprite._Height = 0.5f;
pSprite._Animate = false;;
pSprite._Y = 1.0f;
pSprite._X = fLX;
pSprite._Z = fLZ;
pSprite._Alive = false;
_LivesSprites.Add(pSprite);
fLX += 0.6f;
}
_Starfield = GameObject.Find("Starfield").GetComponent<Renderer>().sharedMaterial;
_Warp = 0.0f;
_Speed = 1.0f;
_PatheEditor = false;
_Generator = new Generator();
_Scores = GameObject.Find("Scores").GetComponent<Scores>();
// Load HUD indicators
_BulletSpeedUp = Sprite.Spawn(1);
_BulletSpeedUp.AddFrame("FasterShot1.png");
_BulletSpeedUp.AddFrame("FasterShot2.png");
_BulletSpeedUp.AddFrame("FasterShot3.png");
_BulletSpeedUp.AddFrame("FasterShot4.png");
_BulletSpeedUp.AddFrame("FasterShot5.png");
_BulletSpeedUp.AddFrame("FasterShot6.png");
_BulletSpeedUp.AddFrame("FasterShot7.png");
_BulletSpeedUp.AddFrame("FasterShot8.png");
_BulletSpeedUp.AddFrame("FasterShot9.png");
_BulletSpeedUp.AddFrame("FasterShot10.png");
_BulletSpeedUp._X = -10.0f;
_BulletSpeedUp._Z = 10.0f;
_BulletSpeedUp._Height = 1.2f;
_BulletSpeedUp._Width = 1.2f;
_BulletSpeedUp._Animate = false;
_BulletSpeedUp._Y = 0.1f;
_BulletSpeedUp._Alive = false;
}
示例8: LoadSprite
public Sprite LoadSprite(XElement element)
{
int width = element.GetAttribute<int>("width");
int height = element.GetAttribute<int>("height");
Sprite sprite = new Sprite(width, height);
sprite.Name = element.TryAttribute<string>("name");
sprite.Part = element.TryAttribute<string>("part");
sprite.PaletteName = element.TryAttribute<string>("palette");
sprite.Reversed = element.TryAttribute<bool>("reversed");
XElement hotspot = element.Element("Hotspot");
if (hotspot != null)
{
int hx = hotspot.GetAttribute<int>("x");
int hy = hotspot.GetAttribute<int>("y");
sprite.HotSpot = new Point(hx, hy);
}
else
{
sprite.HotSpot = new Point(0, 0);
}
sprite.Layer = element.TryAttribute<int>("layer");
XElement stylenode = element.Element("AnimStyle");
if (stylenode != null)
{
string style = stylenode.Value;
switch (style)
{
case "Bounce": sprite.AnimStyle = AnimationStyle.Bounce; break;
case "PlayOnce": sprite.AnimStyle = AnimationStyle.PlayOnce; break;
}
}
XElement directionNode = element.Element("AnimDirection");
if (directionNode != null)
{
string direction = directionNode.Value;
switch (direction)
{
case "Forward": sprite.AnimDirection = AnimationDirection.Forward; break;
case "Backward": sprite.AnimDirection = AnimationDirection.Backward; break;
}
}
foreach (XElement frame in element.Elements("Frame"))
{
int duration = frame.TryAttribute<int>("duration");
int x = frame.GetAttribute<int>("x");
int y = frame.GetAttribute<int>("y");
sprite.AddFrame(x, y, duration);
}
if (sprite.Count == 0)
{
sprite.AddFrame(0, 0, 0);
}
return sprite;
}
示例9: Start
// Use this for initialization
void Start()
{
_Transform = this.transform;
_FireRepeatDelayReset = 0.25f;
_FireRepeatDelay = 0.0f;
// Setup the sprite
_Sprite = Sprite.Spawn(1);
_Sprite.AddFrame("PlayerF1.png");
_Sprite.AddFrame("PlayerF2.png");
_Sprite.AddFrame("PlayerF3.png");
_Sprite._X = 0.0f;
_Sprite._Y = 0.1f;
_Sprite._Z = 0.0f;
_Sprite._Width = 1.8f;
_Sprite._Height = 1.8f;
_Sprite._Animate = true;
_Alive = false;
_Radius = 0.75f;
_XOffset = 0.0f;
_ZOffset = 0.0f;
_XPosition = 0.0f;
_ZPosition = 0.0f;
_X = 0.0f;
_Z = 0.0f;
_Pos = new Vector3(0.0f,0.0f,0.0f);
_LowerX = Ground._Instance._HigherX;
_LowerZ = Ground._Instance._HigherZ;
_HigherX = Ground._Instance._LowerX;
_HigherZ = Ground._Instance._LowerZ;
Debug.Log("LX = " + _LowerX + " HX = " + _HigherX + " LZ = " + _LowerZ + " HZ = " + _HigherZ);
_HalfWidth = 1.0f * 0.5f;
_HalfHeight = (1.0f * 0.5f) * Director._Instance._Aspect;
}
示例10: GetEmptySprite
private static Sprite GetEmptySprite(int frames)
{
var sprite = new Sprite(1, 1);
for (int i = 0; i < frames; i++)
{
sprite.AddFrame(0, 0, 1);
}
return sprite;
}
示例11: UpdateAndRender
public bool UpdateAndRender(float fTimeDelta)
{
if(_Sprite == null)
{
_Sprite = Sprite.Spawn(1);
if(_Type == 0)
{
_Sprite.AddFrame("Bullet.png");
}
else if(_Type == 1)
{
_Sprite.AddFrame("BulletUp.png");
}
else
{
_Sprite.AddFrame("BulletDown.png");
}
_Sprite._Width = 1.0f;
_Sprite._Height = 1.0f;
_Sprite._AI = null;
_Sprite._Bullet = this;
}
_X += _VX * _Speed * fTimeDelta;
_Z += _VZ * _Speed * fTimeDelta;
if(_Collide != null)
{
_Collide(this);
if(!_Alive)
{
return false;
}
}
if(_X > _MaxX)
{
return false;
}
if(_Z > 12.0f)
{
return false;
}
if(_Z < -12.0f)
{
return false;
}
_Sprite._X = _X;
_Sprite._Y = 0.1f;
_Sprite._Z = _Z;
return true;
}
示例12: Setup
private void Setup()
{
_AddedToDelegates = false;
_Pause = false;
_Kill = false;
_Time = Random.Range(0.0f,100.0f);
_TimeToFire = 1.0f;
switch(_Type)
{
case eAIType.AITYPE_ENEMY1:
_Sprite = Sprite.Spawn(1);
_Sprite.AddFrame("Enemy1F1.png");
_Sprite.AddFrame("Enemy1F2.png");
_Sprite.AddFrame("Enemy1F3.png");
_Sprite.AddFrame("Enemy1F4.png");
_Sprite.AddFrame("Enemy1F3.png");
_Sprite.AddFrame("Enemy1F2.png");
_Sprite._Width = 1.2f;
_Sprite._Height = 1.2f;
_Sprite._Animate = true;
_Sprite._Y = 0.1f;
_Radius = 0.5f;
_Speed = 10.0f + Random.Range(0.0f,3.0f);
_Value = 1;
_AABBCollision = false;
_HitPoints = 1;
_Width = 0.5f * 0.5f;
_Height = (0.5f * 0.5f) * Director._Instance._Aspect;
_FrameAdvanceOnHit = false;
_TimeToFire = Random.Range(2.0f,3.0f);
AddToDelegates();
break;
case eAIType.AITYPE_BLOCK:
_Sprite = Sprite.Spawn(1);
switch(_Block)
{
case 1:
_Sprite.AddFrame("Block1.png");
break;
case 2:
_Sprite.AddFrame("Block2.png");
break;
case 3:
_Sprite.AddFrame("Block3.png");
break;
case 4:
_Sprite.AddFrame("Block4.png");
break;
case 5:
_Sprite.AddFrame("Block5.png");
break;
case 6:
_Sprite.AddFrame("Block6.png");
break;
case 7:
_Sprite.AddFrame("Block7.png");
break;
case 8:
_Sprite.AddFrame("Block8.png");
break;
}
_Sprite._Width = 2.0f;
_Sprite._Height = 2.0f;
_Sprite._Animate = false;
_Sprite._Y = 0.0f;
_Radius = 0.8f;
_Speed = 10.0f;
_Value = 1;
_AABBCollision = false;
_HitPoints = 1;
_Width = 0.5f * 0.5f;
_Height = (0.5f * 0.5f) * Director._Instance._Aspect;
_FrameAdvanceOnHit = false;
_TimeToFire = Random.Range(2.0f,3.0f);
AddToDelegates();
break;
case eAIType.AITYPE_RDEFENDER:
_Sprite = Sprite.Spawn(1);
_Sprite.AddFrame("RDefenderF1.png");
_Sprite.AddFrame("RDefenderF2.png");
_Sprite.AddFrame("RDefenderF3.png");
_Sprite.AddFrame("RDefenderF4.png");
_Sprite.AddFrame("RDefenderF5.png");
_Sprite.AddFrame("RDefenderF6.png");
_Sprite.AddFrame("RDefenderF7.png");
_Sprite.AddFrame("RDefenderF8.png");
_Sprite.AddFrame("RDefenderF9.png");
//.........这里部分代码省略.........
示例13: 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)
//.........这里部分代码省略.........