public Entity CreateAtCenter(string spriteName, Action OnClick) { var entity = Create(spriteName, new Vector2(0, 0), OnClick); var transform = entity.Get <Transform>(); transform.Position = SceneUtil.GetCenterFor(entity, _device); entity.Set(transform); return(entity); }
private void CreateGameOver(World world) { var entity = world.CreateEntity(); entity.Set(new SpriteRenderer()); entity.Set(new ManagedResource <string, Texture2D>("gameOver")); var position = SceneUtil.GetCenterFor(entity, _game.GraphicsDevice); entity.Set(new Transform { Position = Vector2.Subtract(position, new Vector2(0, 200)) }); }
private void CreateScoreText() { var entity = _textFactory.Create( new TextArgs { FontName = "font", Text = $"Score: {PlayerPrefs.Get<int>("Score")}", Color = new Color(161, 63, 16) } ); var position = SceneUtil.GetCenterFor(entity, _game.GraphicsDevice); entity.Set(new Transform { Position = position }); }
public Entity Create() { var entity = _world.CreateEntity(); entity.Set( new SpriteRenderer { Texture = _background, Destination = new Rectangle(0, 0, _background.Width * _cellSize, _background.Height * _cellSize) } ); var position = Vector2.Add(SceneUtil.GetCenterFor(entity, _device), new Vector2(0, 30)); entity.Set(new Transform { Position = position }); entity.Set(new Grid(_width, _height)); entity.Set(new GenerationZone { NewCellPositionsInGrid = GridUtil.GetFullGridMatrix(_width, _height), VerticalOffset = 0 }); return(entity); }