コード例 #1
0
ファイル: EntityFactory.cs プロジェクト: MichalKubik/GameTest
        public Entity createPlayer(Vector2 position, Size2 size)
        {
            Entity entity = _entityComponentSystem.CreateEntity("Player", position);

            entity.AttachComponent(new TransformableComponent <Sprite>(new Sprite(Game1.Instance.Content.Load <Texture2D>("magus_small"))));
            entity.AttachComponent(new CollisionBody(size));

            return(entity);
        }
コード例 #2
0
        public Entity CreatePlayer(Vector2 position)
        {
            var entity           = _entityComponentSystem.CreateEntity(Entities.Player, position);
            var textureRegion    = _characterTextureAtlas[0];
            var animationFactory = new SpriteSheetAnimationFactory(_characterTextureAtlas);

            animationFactory.Add("idle", new SpriteSheetAnimationData(new[] { 12, 13 }, 1.0f));
            animationFactory.Add("walk", new SpriteSheetAnimationData(new[] { 0, 1, 2, 3 }));
            animationFactory.Add("jump", new SpriteSheetAnimationData(new[] { 8, 9 }, isLooping: false));

            entity.AttachComponent(new TransformableComponent <Sprite>(new AnimatedSprite(animationFactory)));
            entity.AttachComponent(new BasicCollisionBody(textureRegion.Size, Vector2.One * 0.5f));
            entity.AttachComponent(new PlayerCollisionHandler());
            entity.AttachComponent(new CharacterState());
            entity.Tag = Entities.Player;

            return(entity);
        }