public void Draw(TextureContext texture, VertexPositionColorTexture[] vertices, int offset, int count) { CheckValid(texture); if (count % 4 != 0) { throw new ArgumentException("Vertices must be provided in multiples of 4"); } CheckState(texture); while (count > 0) { if (_vertices.Length - _vBufferIndex < count) { Flush(); } int copyCount = Math.Min(vertices.Length, count); Array.Copy(vertices, offset, _vertices, _vBufferIndex, copyCount); _vBufferIndex += copyCount; count -= copyCount; if (count == 0) { break; } } }
public AtlasRegion(TextureContext texture, int x, int y, int width, int height) : base(texture, x, y, width, height) { OriginalWidth = width; OriginalHeight = height; PackedWidth = width; PackedHeight = height; }
public TextureRegion(TextureContext texture) { if (texture == null) throw new ArgumentNullException("texture"); Texture = texture; SetRegion(0, 0, texture.Width, texture.Height); }
public TextureRegion(TextureContext texture) { if (texture == null) { throw new ArgumentNullException("texture"); } Texture = texture; SetRegion(0, 0, texture.Width, texture.Height); }
private void CheckValid(TextureContext texture) { if (texture == null || texture.Texture == null) { throw new ArgumentNullException("texture"); } if (!_inBegin) { throw new InvalidOperationException("Draw was called, but Begin has not yet been called."); } }
public Sprite(TextureContext texture, int srcX, int srcY, int srcWidth, int srcHeight) { if (texture == null) throw new ArgumentNullException("texture"); Texture = texture; Color = new Color(1f, 1f, 1f, 1f); SetRegion(srcX, srcY, srcWidth, srcHeight); SetSize(Math.Abs(srcWidth), Math.Abs(srcHeight)); SetOrigin(Width / 2, Height / 2); }
public Sprite(TextureContext texture, int srcX, int srcY, int srcWidth, int srcHeight) { if (texture == null) { throw new ArgumentNullException("texture"); } Texture = texture; Color = new Color(1f, 1f, 1f, 1f); SetRegion(srcX, srcY, srcWidth, srcHeight); SetSize(Math.Abs(srcWidth), Math.Abs(srcHeight)); SetOrigin(Width / 2, Height / 2); }
public AtlasRegion AddRegion(string name, TextureContext texture, int x, int y, int width, int height) { Textures.Add(texture); AtlasRegion region = new AtlasRegion(texture, x, y, width, height) { Name = name, OriginalWidth = width, OriginalHeight = height, Index = -1, }; Regions.Add(region); return(region); }
private void Load(GraphicsDevice graphicsDevice, TextureAtlasData data) { Dictionary <TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary <TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(graphicsDevice, page.TextureFile, true); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
private void CheckState(TextureContext texture) { if (texture != _lastTexture) { SwitchTexture(texture); } if (_lastScissors != _device.ScissorRectangle) { Rectangle newScissors = _device.ScissorRectangle; _device.ScissorRectangle = _lastScissors; Flush(); _device.ScissorRectangle = newScissors; _lastScissors = newScissors; } }
private void Load(ContentManager contentManager, TextureAtlasData data) { Dictionary <TextureAtlasData.Page, TextureContext> pageToTexture = new Dictionary <TextureAtlasData.Page, TextureContext>(); foreach (var page in data.Pages) { TextureContext texture = page.Texture ?? new TextureContext(contentManager, page.TextureFile, false); texture.Filter = page.Filter; texture.WrapU = page.UWrap; texture.WrapV = page.VWrap; Textures.Add(texture); pageToTexture[page] = texture; } LoadRegions(data, pageToTexture); }
public void Draw(TextureContext texture, float x, float y, float width, float height, float u, float v, float u2, float v2) { CheckValid(texture); CheckState(texture); if (_vertices.Length - _vBufferIndex < 4) { Flush(); } float fx2 = x + width; float fy2 = y + height; Color color = Color.FromNonPremultiplied(Color.R, Color.G, Color.B, Color.A); _vertices[_vBufferIndex + 0] = new VertexPositionColorTexture(new Vector3(x, y, 0), color, new Vector2(u, v)); _vertices[_vBufferIndex + 1] = new VertexPositionColorTexture(new Vector3(x, fy2, 0), color, new Vector2(u, v2)); _vertices[_vBufferIndex + 2] = new VertexPositionColorTexture(new Vector3(fx2, fy2, 0), color, new Vector2(u2, v2)); _vertices[_vBufferIndex + 3] = new VertexPositionColorTexture(new Vector3(fx2, y, 0), color, new Vector2(u2, v)); _vBufferIndex += 4; }
public static TextureRegion[,] Split(TextureContext texture, int tileWidth, int tileHeight) { TextureRegion region = new TextureRegion(texture); return region.Split(tileWidth, tileHeight); }
private void CheckValid(TextureContext texture) { if (texture == null || texture.Texture == null) throw new ArgumentNullException("texture"); if (!_inBegin) throw new InvalidOperationException("Draw was called, but Begin has not yet been called."); }
private void SwitchTexture(TextureContext texture) { Flush(); _lastTexture = texture; }
public NinePatch(TextureContext texture, Color color) : this(texture) { Color = color; }
public void SetRegion(TextureContext texture) { Texture = texture; SetRegion(0, 0, texture.Width, texture.Height); }
public TextureRegion(TextureContext texture, int width, int height) { Texture = texture; SetRegion(0, 0, width, height); }
public TextureRegion(TextureContext texture, float u, float v, float u2, float v2) { Texture = texture; SetRegion(u, v, u2, v2); }
public NinePatch(TextureContext texture, int left, int right, int top, int bottom) : this(new TextureRegion(texture), left, right, top, bottom) { }
public Sprite(TextureContext texture) : this(texture, 0, 0, texture.Width, texture.Height) { }
public Sprite(TextureContext texture, int srcWidth, int srcHeight) : this(texture, 0, 0, srcWidth, srcHeight) { }
public TextureRegion(TextureContext texture, int x, int y, int width, int height) { Texture = texture; SetRegion(x, y, width, height); }
public static TextureRegion[,] Split(TextureContext texture, int tileWidth, int tileHeight) { TextureRegion region = new TextureRegion(texture); return(region.Split(tileWidth, tileHeight)); }
public NinePatch(TextureContext texture) : this(new TextureRegion(texture)) { }
public void Draw(TextureContext texture, float x, float y, float width, float height, float u, float v, float u2, float v2) { CheckValid(texture); CheckState(texture); if (_vertices.Length - _vBufferIndex < 4) Flush(); float fx2 = x + width; float fy2 = y + height; Color color = Color.FromNonPremultiplied(Color.R, Color.G, Color.B, Color.A); _vertices[_vBufferIndex + 0] = new VertexPositionColorTexture(new Vector3(x, y, 0), color, new Vector2(u, v)); _vertices[_vBufferIndex + 1] = new VertexPositionColorTexture(new Vector3(x, fy2, 0), color, new Vector2(u, v2)); _vertices[_vBufferIndex + 2] = new VertexPositionColorTexture(new Vector3(fx2, fy2, 0), color, new Vector2(u2, v2)); _vertices[_vBufferIndex + 3] = new VertexPositionColorTexture(new Vector3(fx2, y, 0), color, new Vector2(u2, v)); _vBufferIndex += 4; }
public Image(TextureContext texture) : this(new TextureRegionDrawable(new TextureRegion(texture))) { }
private void CheckState(TextureContext texture) { if (texture != _lastTexture) SwitchTexture(texture); if (_lastScissors != _device.ScissorRectangle) { Rectangle newScissors = _device.ScissorRectangle; _device.ScissorRectangle = _lastScissors; Flush(); _device.ScissorRectangle = newScissors; _lastScissors = newScissors; } }
protected override void InitializeCore() { ShowDebug = true; //Debugger.Launch(); _spriteBatch = new GdxSpriteBatch(Context.GraphicsDevice); _skin = new Skin(Context.GraphicsDevice, "Data/uiskin.json"); _texture1 = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true); _texture2 = new TextureContext(Context.GraphicsDevice, "Data/badlogic.jpg", true); TextureRegion image = new TextureRegion(_texture1); TextureRegion imageFlipped = new TextureRegion(image); imageFlipped.Flip(true, true); TextureRegion image2 = new TextureRegion(_texture2); _stage = new Stage(Context.GraphicsDevice.Viewport.Width, Context.GraphicsDevice.Viewport.Height, true, Context.GraphicsDevice); Context.Input.Processor = _stage; ImageButtonStyle style = new ImageButtonStyle(_skin.Get<ButtonStyle>()) { ImageUp = new TextureRegionDrawable(image), ImageDown = new TextureRegionDrawable(imageFlipped), }; ImageButton iconButton = new ImageButton(style); Button buttonMulti = new TextButton("Multi\nLine\nToggle", _skin, "toggle") { IsToggle = true, }; Button imgButton = new Button(new Image(image), _skin); Button imgToggleButton = new Button(new Image(image), _skin, "toggle") { IsToggle = true, }; Label myLabel = new Label("This is some text.", _skin); myLabel.TextWrapping = true; Table t = new Table(); t.Row(); t.Add(myLabel); t.Layout(); CheckBox checkbox = new CheckBox("Check me", _skin); Slider slider = new Slider(0, 10, 1, false, _skin); TextField textField = new TextField("", _skin) { MessageText = "Click here!", }; SelectBox dropdown = new SelectBox(selectEntries, _skin); Image imageActor = new Image(image2); ScrollPane scrollPane = new ScrollPane(imageActor); MonoGdx.Scene2D.UI.List list = new MonoGdx.Scene2D.UI.List(listEntries, _skin); ScrollPane scrollPane2 = new ScrollPane(list, _skin); //scrollPane2.FlickScroll = false; SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, _skin, "default-horizontal"); _fpsLabel = new Label("fps:", _skin); Label passwordLabel = new Label("Textfield in password mode: ", _skin); TextField passwordField = new TextField("", _skin) { MessageText = "password", PasswordCharacter = '*', IsPasswordMode = true, }; Window window = new Window("Dialog", _skin); window.SetPosition(0, 0); window.Defaults().SpaceBottom = 10; window.Row().Configure.Fill().ExpandX(); window.Add(iconButton); window.Add(buttonMulti); window.Add(imgButton); window.Add(imgToggleButton); window.Row(); window.Add(checkbox); window.Add(slider).Configure.MinWidth(100).FillX().Colspan(3); window.Row(); window.Add(dropdown).Configure.MinWidth(100).FillX(); window.Add(textField).Configure.MinWidth(100).ExpandX().FillX().Colspan(3); window.Row(); window.Add(splitPane).Configure.Fill().Expand().Colspan(4).MaxHeight(200); window.Row(); window.Add(passwordLabel).Configure.Colspan(2); window.Add(passwordField).Configure.MinWidth(100).ExpandX().FillX().Colspan(2); window.Pack(); /*textField.KeyUp += (field, c) => { if (c == '\n') field.OnscreenKeyboard.Show(false); };*/ _stage.AddActor(window); MonoGdx.Scene2D.UI.List list2 = new MonoGdx.Scene2D.UI.List(listEntries, _skin); ScrollPane scrollPane22 = new ScrollPane(list2, _skin); Window window2 = new Window("ScrollPane", _skin); window2.SetPosition(300, 300); window2.Defaults().SpaceBottom = 10; window2.Row().Configure.Fill().ExpandX(); window2.Add(scrollPane22).Configure.MaxHeight(250).MaxWidth(150); window2.Pack(); _stage.AddActor(window2); }
private void FillGroup(Group group, TextureContext texture) { float advance = 32 + Spacing; for (int y = 0; y < NumSprites * advance; y += (int)advance) { for (int x = 0; x < NumSprites * advance; x += (int)advance) { Image img = new Image(new TextureRegion(texture)) { Align = Alignment.Center, Scaling = Scaling.None, }; img.SetBounds(x, y, 32, 32); img.SetOrigin(16, 16); group.AddActor(img); _images.Add(img); } } }
public AtlasRegion AddRegion(string name, TextureContext texture, int x, int y, int width, int height) { Textures.Add(texture); AtlasRegion region = new AtlasRegion(texture, x, y, width, height) { Name = name, OriginalWidth = width, OriginalHeight = height, Index = -1, }; Regions.Add(region); return region; }
public void Draw(TextureContext texture, VertexPositionColorTexture[] vertices, int offset, int count) { CheckValid(texture); if (count % 4 != 0) throw new ArgumentException("Vertices must be provided in multiples of 4"); CheckState(texture); while (count > 0) { if (_vertices.Length - _vBufferIndex < count) Flush(); int copyCount = Math.Min(vertices.Length, count); Array.Copy(vertices, offset, _vertices, _vBufferIndex, copyCount); _vBufferIndex += copyCount; count -= copyCount; if (count == 0) break; } }
protected override void InitializeCore() { ShowDebug = true; _texture = new TextureContext(Context.GraphicsDevice, "Data/badlogicsmall.jpg", true); _font = new BitmapFont(Context.GraphicsDevice, "Data/arial-15.fnt", "data/arial-15_00.png", false); _stage = new Stage(480, 320, true, Context.GraphicsDevice); float loc = (NumSprites * (32 + Spacing) - Spacing) / 2; for (int i = 0; i < NumGroups; i++) { Group group = new Group() { X = (float)(_rand.NextDouble() * (_stage.Width - NumSprites * (32 + Spacing))), Y = (float)(_rand.NextDouble() * (_stage.Height - NumSprites * (32 + Spacing))), OriginX = loc, OriginY = loc, //Rotation = MathHelper.ToRadians(30), }; FillGroup(group, _texture); _stage.AddActor(group); } _uiTexture = new TextureContext(Context.GraphicsDevice, "Data/ui.png", true); _ui = new Stage(480, 320, false, Context.GraphicsDevice); Image blend = new Image(new TextureRegion(_uiTexture, 0, 0, 64, 32)) { Align = Alignment.Center, Scaling = Scaling.None, }; // Listener blend.Y = _ui.Height - 64; Image rotate = new Image(new TextureRegion(_uiTexture, 64, 0, 64, 32)) { Align = Alignment.Center, Scaling = Scaling.None, }; rotate.TouchDown += (s, e) => { _rotateSprites = !_rotateSprites; e.Handled = true; }; /*rotate.AddListener(new TouchListener() { Down = (e, x, y, pointer, button) => { _rotateSprites = !_rotateSprites; return true; } });*/ rotate.SetPosition(64, blend.Y); Image scale = new Image(new TextureRegion(_uiTexture, 64, 32, 64, 32)) { Align = Alignment.Center, Scaling = Scaling.None, }; scale.TouchDown += (s, e) => { _scaleSprites = !_scaleSprites; e.Handled = true; }; /*scale.AddListener(new TouchListener() { Down = (e, x, y, pointer, button) => { _scaleSprites = !_scaleSprites; return true; } });*/ scale.SetPosition(128, blend.Y); _ui.AddActor(blend); _ui.AddActor(rotate); _ui.AddActor(scale); /*_fps = new Label("fps: 0", new LabelStyle(_font, Color.White)); _fps.SetPosition(10, 30); _fps.Color = new Color(0, 1f, 0, 1f); _ui.AddActor(_fps);*/ }