本文整理汇总了C#中Transform2D类的典型用法代码示例。如果您正苦于以下问题:C# Transform2D类的具体用法?C# Transform2D怎么用?C# Transform2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform2D类属于命名空间,在下文中一共展示了Transform2D类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:dezol,项目名称:QuickStarters,代码行数:30,代码来源:ChildrenRectangle.cs
示例2: Text
public Text(
string textContent,
SpriteFont spriteFont,
Transform2D parentTransform = null)
: this(textContent, spriteFont, new Transform2D(), parentTransform)
{
}
开发者ID:AlexanderKrustev,项目名称:SoftUni,代码行数:7,代码来源:Text.cs
示例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>();
}
开发者ID:dezol,项目名称:QuickStarters,代码行数:10,代码来源:EnemyBehavior.cs
示例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;
}
开发者ID:dezol,项目名称:QuickStarters,代码行数:7,代码来源:LinkedRopeBehavior.cs
示例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();
};
}
开发者ID:joeromero,项目名称:QuickStarters,代码行数:35,代码来源:BackgroundKite.cs
示例6: Identity2D
public Identity2D(bool DependsOnCamera)
{
Transform = Transform2D.Identity;
Parent = null;
this.DependsOnCamera = DependsOnCamera;
}
开发者ID:iLambda,项目名称:Freemwork,代码行数:7,代码来源:Identity2D.cs
示例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;
}
开发者ID:huodianyan,项目名称:Components,代码行数:18,代码来源:SpriteRenderer.cs
示例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;
}
开发者ID:huodianyan,项目名称:Components,代码行数:13,代码来源:AnimatedSpriteRenderer.cs
示例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;
}
开发者ID:nagyistoce,项目名称:WaveEngine-Components,代码行数:13,代码来源:ImageControlRenderer.cs
示例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;
}
开发者ID:joanjosepeivissa,项目名称:Components,代码行数:13,代码来源:SpriteRenderer.cs
示例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;
}
开发者ID:123asd123A,项目名称:Samples,代码行数:9,代码来源:PlayerAIBehavior.cs
示例12: Initialize
protected override void Initialize()
{
base.Initialize();
if (!string.IsNullOrEmpty(this.TargetPath))
{
this.targetTrasnform = this.EntityManager.Find(this.TargetPath)?.FindComponent<Transform2D>();
}
}
开发者ID:WaveEngine,项目名称:Samples,代码行数:9,代码来源:CarCameraBehavior.cs
示例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>();
}
开发者ID:DeveloperSkeletor,项目名称:QuickStarters,代码行数:13,代码来源:GamePlaySceneBehavior.cs
示例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;
}
开发者ID:joanjosepeivissa,项目名称:Components,代码行数:14,代码来源:AnimatedSpriteRenderer.cs
示例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");
}
}
开发者ID:dezol,项目名称:QuickStarters,代码行数:12,代码来源:Follower2DBehavior.cs
示例16: ResolveDependencies
/// <summary>
/// Resolves the dependencies needed for this instance to work.
/// </summary>
protected override void ResolveDependencies()
{
base.ResolveDependencies();
var playerEntity = this.EntityManager.Find("Player");
if (playerEntity != null)
{
this.player = playerEntity.FindComponent<PlayerBehavior>();
this.playerTransform = playerEntity.FindComponent<Transform2D>();
}
}
开发者ID:DeveloperSkeletor,项目名称:QuickStarters,代码行数:15,代码来源:EnemyBehavior.cs
示例17: Initialize
protected override void Initialize()
{
base.Initialize();
this.followTransform = this.followEntity.FindComponent<Transform2D>();
this.virtualScreenManager = this.Owner.Scene.VirtualScreenManager;
this.platform = WaveServices.Platform;
this.platform.OnScreenSizeChanged += OnScreenSizeChanged;
this.RefreshCameraLimits();
}
开发者ID:WaveEngine,项目名称:Samples,代码行数:12,代码来源:CameraBehavior.cs
示例18: JumpButton
/// <summary>
/// Initializes a new instance of the <see cref="JumpButton" /> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="area">The area.</param>
public JumpButton(string name, RectangleF area)
{
// Touch area
this.entity = new Entity(name)
.AddComponent(new Transform2D()
{
X = area.X,
Y = area.Y,
Rectangle = new RectangleF(0, 0, area.Width, area.Height),
})
.AddComponent(new RectangleCollider2D())
.AddComponent(new TouchGestures());
// Thumb
this.thumb = new Entity()
.AddComponent(new Transform2D()
{
Origin = Vector2.Center,
DrawOrder = 0.1f,
})
.AddComponent(new Sprite(WaveContent.Assets.joystickThumb_png))
.AddComponent(new SpriteRenderer(DefaultLayers.Alpha));
this.thumb.IsVisible = false;
this.thumbTransform = this.thumb.FindComponent<Transform2D>();
this.entity.AddChild(this.thumb);
// Touch Events
var touch = this.entity.FindComponent<TouchGestures>();
touch.TouchPressed += (s, o) =>
{
this.pressedPosition = o.GestureSample.Position;
this.thumbTransform.X = this.pressedPosition.X;
this.thumbTransform.Y = this.pressedPosition.Y;
this.thumb.IsVisible = true;
this.IsShooting = true;
};
touch.TouchMoved += (s, o) =>
{
Vector2 deltaTouch = this.pressedPosition - o.GestureSample.Position;
this.thumbTransform.X = this.pressedPosition.X - deltaTouch.X;
this.thumbTransform.Y = this.pressedPosition.Y - deltaTouch.Y;
};
touch.TouchReleased += (s, o) =>
{
this.thumb.IsVisible = false;
this.IsShooting = false;
};
}
开发者ID:julietsvq,项目名称:Samples,代码行数:57,代码来源:JumpButton.cs
示例19: Sprite
/// <summary>
/// Initializes a new instance of the <see cref="Sprite" /> class.
/// </summary>
/// <param name="texturePath">The texture path.</param>
/// <exception cref="System.ArgumentException">TexturePath can not be null.</exception>
public Sprite(string texturePath)
: base("Sprite" + instances++)
{
if (string.IsNullOrEmpty(texturePath))
{
throw new ArgumentException("TexturePath can not be null.");
}
this.SourceRectangle = null;
this.Transform2D = null;
this.isGlobalAsset = false;
this.TexturePath = texturePath;
this.TintColor = Color.White;
}
开发者ID:kguner,项目名称:Components,代码行数:19,代码来源:Sprite.cs
示例20: SpriteAtlas
/// <summary>
/// Initializes a new instance of the <see cref="SpriteAtlas" /> class.
/// </summary>
/// <param name="atlasPath">The path to the atlas.</param>
/// <param name="textureName">Name of the texture from where this atlas is loaded.</param>
/// <exception cref="System.ArgumentException">TexturePath can not be null.</exception>
public SpriteAtlas(string atlasPath, string textureName)
: base("SpriteAtlas" + instances++)
{
if (string.IsNullOrEmpty(atlasPath))
{
throw new ArgumentException("TexturePath can not be null.");
}
this.TextureName = textureName;
this.Transform2D = null;
this.isGlobalAsset = false;
this.AtlasPath = atlasPath;
this.TintColor = Color.White;
}
开发者ID:kguner,项目名称:Components,代码行数:20,代码来源:SpriteAtlas.cs
注:本文中的Transform2D类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论