|
using System;
using System.Drawing;
using System.Collections;
namespace Endogine.Editors
{
/// <summary>
/// Summary description for SpriteMarker.
/// </summary>
public class BhSpriteMarker : Behavior
{
protected int m_nCnt = 0;
protected ArrayList m_aSprites;
public BhSpriteMarker()
{
m_aSprites = new ArrayList();
for (int i = 0; i < 4; i++)
{
Sprite sp = new Sprite();
sp.MemberName = "Cross";
sp.LocZ = 1000;
m_aSprites.Add(sp);
}
}
public override void Dispose()
{
foreach (Sprite sp in m_aSprites)
sp.Dispose();
base.Dispose();
}
protected override void EnterFrame()
{
base.EnterFrame();
if (m_sp.Rect == null)
return;
ERectangleF rct = new ERectangleF(
m_sp.ConvParentLocToRootLoc(m_sp.Rect.Location),
m_sp.ConvParentLocToRootLoc(m_sp.Rect.Size));
for (int i = 0; i < m_aSprites.Count; i++)
{
Sprite sp = (Sprite)m_aSprites[i];
sp.Loc = GetWhereOnSides((float)((m_nCnt+100*i/m_aSprites.Count) % 100)/100, rct);
}
m_nCnt++;
}
protected EPointF GetWhereOnSides(float fPhase, ERectangleF rct)
{
float fCircum = rct.Width*2 + rct.Height*2;
EPointF pnt = new EPointF();
if (fPhase < rct.Width/fCircum)
{
pnt.X = rct.X+fPhase*fCircum;
pnt.Y = rct.Y;
}
else
{
fPhase-= rct.Width/fCircum;
if (fPhase < rct.Height/fCircum)
{
pnt.X = rct.Right;
pnt.Y = rct.Y+fPhase*fCircum;
}
else
{
fPhase-= rct.Height/fCircum;
if (fPhase < rct.Width/fCircum)
{
pnt.Y = rct.Bottom;
pnt.X = rct.Right-fPhase*fCircum;
}
else
{
fPhase-= rct.Width/fCircum;
pnt.X = rct.X;
pnt.Y = rct.Bottom-fPhase*fCircum;
}
}
}
return pnt;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.