本文整理汇总了C#中Transform2D类的典型用法代码示例。如果您正苦于以下问题:C# Transform2D类的具体用法?C# Transform2D怎么用?C# Transform2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Transform2D类属于命名空间,在下文中一共展示了Transform2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTotalRectangle
private RectangleF GetTotalRectangle(Entity entity, Transform2D parentTransform2D)
{
RectangleF result = RectangleF.Empty;
var entityTransform = entity.FindComponent<Transform2D>();
if (entityTransform != null)
{
result = entityTransform.Rectangle;
if (parentTransform2D != null)
{
result.Offset(
entityTransform.X - (entityTransform.Rectangle.Width * entityTransform.Origin.X),
entityTransform.Y - (entityTransform.Rectangle.Height * entityTransform.Origin.Y));
result.Offset(
-1 * (parentTransform2D.X - (parentTransform2D.Rectangle.Width * parentTransform2D.Origin.X)),
-1 * (parentTransform2D.Y - (parentTransform2D.Rectangle.Height * parentTransform2D.Origin.Y)));
}
foreach (var child in entity.ChildEntities)
{
var childTotalRectangle = this.GetTotalRectangle(child, entityTransform);
RectangleF.Union(ref result, ref childTotalRectangle, out result);
}
}
return result;
}
示例2: Text
public Text(
string textContent,
SpriteFont spriteFont,
Transform2D parentTransform = null)
: this(textContent, spriteFont, new Transform2D(), parentTransform)
{
}
示例3: ResolveDependencies
/// <summary>
/// Resolves the dependencies needed for this instance to work.
/// </summary>
protected override void ResolveDependencies()
{
base.ResolveDependencies();
this.player = EntityManager.Find<Player>("player");
this.playerTransform = this.player.Entity.FindComponent<Transform2D>();
}
示例4: LinkedRopeBehavior
public LinkedRopeBehavior(Entity from, Vector2 fromOrigin, Entity to, Vector2 toOrigin)
{
this.fromTransform = from.FindComponent<Transform2D>();
this.toTransform = to.FindComponent<Transform2D>();
this.fromOrigin = fromOrigin;
this.toOrigin = toOrigin;
}
示例5: BackgroundKite
public BackgroundKite(float initialX)
{
var scale = this.GetRandomScale();
var scrollBehavior = new ScrollBehavior(scale * 0.1f);
var transform = new Transform2D()
{
X = initialX,
Y = WaveServices.ViewportManager.VirtualHeight,
Origin = Vector2.UnitY,
XScale = scale,
YScale = scale
};
var spriteAtlas = new SpriteAtlas(Textures.GAME_ATLAS, this.GetRandomTextureName());
this.entity = new Entity()
.AddComponent(transform)
.AddComponent(spriteAtlas)
.AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque))
.AddComponent(scrollBehavior);
scrollBehavior.EntityOutOfScreen += (entity) =>
{
transform.X = WaveServices.ViewportManager.RightEdge;
var newScale = this.GetRandomScale();
transform.XScale = newScale;
transform.YScale = newScale;
//Set a new kite texture
spriteAtlas.TextureName = this.GetRandomTextureName();
};
}
示例6: Identity2D
public Identity2D(bool DependsOnCamera)
{
Transform = Transform2D.Identity;
Parent = null;
this.DependsOnCamera = DependsOnCamera;
}
示例7: SpriteRenderer
/// <summary>
/// Initializes a new instance of the <see cref="SpriteRenderer" /> class.
/// </summary>
/// <param name="layerType">
/// Layer type (available at <see cref="DefaultLayers"/>).
/// Example: new SpriteRenderer(DefaultLayers.Alpha)
/// </param>
/// <param name="samplerMode">
/// Sampler mode <see cref="AddressMode"/>
/// Example: new SpriteRenderer(DefaultLayers.Alpha)
/// </param>
public SpriteRenderer(Type layerType, AddressMode samplerMode = AddressMode.LinearClamp)
: base("SpriteRenderer" + instances++, layerType)
{
this.Transform2D = null;
this.Sprite = null;
this.samplerMode = samplerMode;
}
示例8: AnimatedSpriteRenderer
/// <summary>
/// Initializes a new instance of the <see cref="AnimatedSpriteRenderer" /> class.
/// </summary>
/// <param name="layer">Layer type.</param>
/// <param name="samplerMode">The sampler mode.</param>
public AnimatedSpriteRenderer(Type layer, AddressMode samplerMode = AddressMode.LinearClamp)
: base("AnimatedSpriteRenderer" + instances++, layer)
{
this.Transform2D = null;
this.Sprite = null;
this.Animation2D = null;
this.samplerMode = samplerMode;
}
示例9: ImageControlRenderer
/// <summary>
/// Initializes a new instance of the <see cref="ImageControlRenderer" /> class.
/// </summary>
/// <param name="layerType">Type of the layer.</param>
public ImageControlRenderer(Type layerType)
: base("ImageRenderer" + instances++, layerType)
{
this.Transform2D = null;
this.Image = null;
this.scale = Vector2.Zero;
this.position = Vector2.Zero;
this.origin = Vector2.Zero;
}
示例10: SpriteRenderer
/// <summary>
/// Initializes a new instance of the <see cref="SpriteRenderer" /> class.
/// </summary>
/// <param name="layerType">Type of the layer.</param>
public SpriteRenderer(Type layerType)
: base("SpriteRenderer" + instances++, layerType)
{
this.Transform2D = null;
this.Sprite = null;
this.scale = Vector2.Zero;
this.position = Vector2.Zero;
this.origin = Vector2.Zero;
}
示例11: PlayerAIBehavior
public PlayerAIBehavior(Entity ball)
: base("PlayerIABehavior")
{
this.trans2D = null;
this.ball = ball;
this.transBall2D = ball.FindComponent<Transform2D>();
this.ballBehavior = ball.FindComponent<BallBehavior>();
this.direction = ballBehavior.HorizontalDirection;
}
示例12: Initialize
protected override void Initialize()
{
base.Initialize();
if (!string.IsNullOrEmpty(this.TargetPath))
{
this.targetTrasnform = this.EntityManager.Find(this.TargetPath)?.FindComponent<Transform2D>();
}
}
示例13: ResolveDependencies
/// <summary>
/// Resolves the dependencies needed for this instance to work.
/// </summary>
protected override void ResolveDependencies()
{
this.gamePlayScene = this.Scene as GamePlayScene;
this.scoreboardPanel = this.gamePlayScene.EntityManager.Find<ScoreboardPanel>("scoreboardPanel");
this.target = this.gamePlayScene.EntityManager.Find<Entity>("BallTarget");
this.targetTransform = this.target.FindComponent<Transform2D>();
this.start = this.gamePlayScene.EntityManager.Find<Entity>("BallStart");
this.startTransform = this.start.FindComponent<Transform2D>();
}
示例14: AnimatedSpriteRenderer
/// <summary>
/// Initializes a new instance of the <see cref="AnimatedSpriteRenderer" /> class.
/// </summary>
/// <param name="layer">Layer type.</param>
public AnimatedSpriteRenderer(Type layer)
: base("AnimatedSpriteRenderer" + instances++, layer)
{
this.Transform2D = null;
this.Sprite = null;
this.scale = Vector2.Zero;
this.position = Vector2.Zero;
this.origin = Vector2.Zero;
this.Animation2D = null;
}
示例15: Follower2DBehavior
public Follower2DBehavior(Entity entity, FollowTypes followType)
{
this.followedTranform = entity.FindComponent<Transform2D>();
this.followType = followType;
this.lastFollowPosition = Vector2.Zero;
if (this.lastFollowPosition == null)
{
throw new NotImplementedException("The Transform2D component must be used by the entity to follow");
}
}