本文整理汇总了C#中Sprite.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.Add方法的具体用法?C# Sprite.Add怎么用?C# Sprite.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTrigger
public void CreateTrigger()
{
var trigger = new Sprite(material, new Rectangle(Vector2D.Zero, (Size)Vector2D.One))
{
Color = Color.Red
};
trigger.Add(new TimeTrigger.Data(Color.Red, Color.Gray, 1));
trigger.Start<CollisionTrigger>().Add(new CollisionTrigger.Data(Color.White, Color.Red));
Assert.AreEqual(Vector2D.Zero, trigger.Get<Rectangle>().TopLeft);
Assert.AreEqual(Vector2D.One, trigger.Get<Rectangle>().BottomRight);
}
示例2: RenderSlowlyFallingLogo
public void RenderSlowlyFallingLogo()
{
var sprite = new Sprite(new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo"),
screenCenter);
sprite.Add(new SimplePhysics.Data
{
Velocity = new Vector2D(0.0f, -0.3f),
RotationSpeed = 100.0f,
Gravity = new Vector2D(0.0f, 0.1f),
});
sprite.Color = Color.Red;
sprite.Start<SimplePhysics.Move>();
}
示例3: CreateFallingSpriteWhichExpires
private static Sprite CreateFallingSpriteWhichExpires()
{
var sprite = new Sprite(new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo"),
Rectangle.One);
sprite.Add(new SimplePhysics.Data
{
Velocity = Vector2D.Half,
Gravity = new Vector2D(1.0f, 2.0f),
Duration = 1.0f
});
sprite.Start<SimplePhysics.Move>();
sprite.Color = Color.Red;
return sprite;
}
示例4: GetSpriteString
public Sprite<string> GetSpriteString(string id)
{
XmlElement xml = sprites[id];
Sprite<string> sprite = new Sprite<string>(atlas[xml.ChildText("Texture")], xml.ChildInt("FrameWidth"), xml.ChildInt("FrameHeight"));
sprite.Origin = new Vector2(xml.ChildFloat("OriginX", 0), xml.ChildFloat("OriginY", 0));
sprite.Position = new Vector2(xml.ChildFloat("X", 0), xml.ChildFloat("Y", 0));
sprite.Color = xml.ChildHexColor("Color", Color.White);
XmlElement anims = xml["Animations"];
if (anims != null)
foreach (XmlElement anim in anims.GetElementsByTagName("Anim"))
sprite.Add(anim.Attr("id"), anim.AttrFloat("delay", 0), anim.AttrBool("loop", true), Calc.ReadCSV(anim.Attr("frames")));
return sprite;
}
示例5: AddFallingBrick
} //ncrunch: no coverage end
private static void AddFallingBrick(Entity2D brick, Material material)
{
var fallingBrick = new Sprite(material, brick.DrawArea)
{
Color = brick.Color,
RenderLayer = (int)BlocksRenderLayer.FallingBrick,
};
var random = Randomizer.Current;
var data = new SimplePhysics.Data
{
Velocity = new Vector2D(random.Get(-0.5f, 0.5f), random.Get(-1.0f, 0.0f)),
RotationSpeed = random.Get(-360, 360),
Duration = 5.0f,
Gravity = new Vector2D(0.0f, 2.0f)
};
fallingBrick.Add(data);
fallingBrick.Start<SimplePhysics.Move>();
}
示例6: KillSpriteAfterTimeout
public void KillSpriteAfterTimeout()
{
var enemyMovingOutOfScreen =
new Sprite(new Material(ShaderFlags.Position2DTextured, "DeltaEngineLogo"),
new Rectangle(Vector2D.Half, new Size(0.1f)));
var data = new SimplePhysics.Data { Velocity = new Vector2D(0.5f, 0), Duration = 1 };
enemyMovingOutOfScreen.Add(data);
enemyMovingOutOfScreen.Start<SimplePhysics.Move>();
enemyMovingOutOfScreen.Start<SimplePhysics.KillAfterDurationReached>();
if (IsMockResolver)
AdvanceTimeAndUpdateEntities(1.1f);
}
示例7: RenderSpriteWithRedOutline
public void RenderSpriteWithRedOutline()
{
var sprite = new Sprite(logoMaterial, Rectangle.HalfCentered);
sprite.Add(new OutlineColor(Color.Red));
sprite.OnDraw<DrawPolygon2DOutlines>();
}
示例8: AddingUVCalculatorResultsThrowsException
public void AddingUVCalculatorResultsThrowsException()
{
var sprite = new Sprite("DeltaEngineLogoAlpha", Rectangle.One);
Assert.Throws<Sprite.RenderingDataComponentAddingIsNotSupported>(
() => sprite.Add(new RenderingData()));
}