当前位置: 首页>>代码示例>>C#>>正文


C# Transform2D类代码示例

本文整理汇总了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;
        }
开发者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


注:本文中的Transform2D类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。