public void SpriteNode() { var tc = new TestCore(); tc.Duration = 2000; tc.Init(); var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var node = new SpriteNode(); //node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200)); node.Texture = texture; node.AdjustSize(); node.Position = new Vector2F(200, 200); node.CenterPosition = texture.Size / 2; node.Scale = new Vector2F(0.2f, 0.2f); Engine.AddNode(node); var col = new CircleCollider(); col.Radius = 200 * 0.2f; col.Position = node.Position; var node2 = new SpriteNode(); //node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200)); node2.Texture = texture; node2.AdjustSize(); node2.Position = new Vector2F(200, 200); node2.CenterPosition = texture.Size / 2; node2.Scale = new Vector2F(0.2f, 0.2f); Engine.AddNode(node2); var col2 = new CircleCollider(); col2.Radius = 200 * 0.2f; col2.Position = node.Position; tc.LoopBody(c => { node2.Position = col2.Position = Engine.Mouse.Position; if (col.GetIsCollidedWith(col2)) { node2.Angle++; } } , null); tc.End(); }
public void Color() { var tc = new TestCore(new Configuration { ToolEnabled = true }); tc.Init(); var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var node = new SpriteNode(); node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200)); node.Texture = texture; node.AdjustSize(); node.CenterPosition = texture.Size / 2; Engine.AddNode(node); var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100); var text = new TextNode() { Font = font, Text = "色テスト", Position = new Vector2F(0.0f, 0.0f) }; Engine.AddNode(text); Color col1 = new Color(10, 20, 50, 100); Color col2 = new Color(10, 20, 50, 100); tc.LoopBody(c => { if (Engine.Tool.Begin("Test", ToolWindow.None)) { Engine.Tool.ColorEdit3("Color1", ref col1, ToolColorEdit.None); // RGB Engine.Tool.ColorEdit4("Color2", ref col2, ToolColorEdit.None); // RGBAのアルファ付き var flag = ToolColorEdit.Float | ToolColorEdit.NoInputs | ToolColorEdit.NoLabel; Engine.Tool.ColorEdit3("Color ID", ref col1, flag); Engine.Tool.End(); } text.Color = col1; } , null); tc.End(); }
public void Anchor() { var tc = new TestCore(); tc.Init(); var font = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 30); Assert.NotNull(font); var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); Assert.NotNull(texture); Vector2F rectSize = texture.Size; var parent = new PolygonNode(); parent.Position = new Vector2F(320, 240); //parent.Pivot = new Vector2F(0.5f, 0.5f); parent.SetVertexes(new[] { new Vector2F(0, 0), new Vector2F(rectSize.X, 0), new Vector2F(rectSize.X, rectSize.Y), new Vector2F(0, rectSize.Y), }, new Color(255, 255, 255, 255)); parent.AdjustSize(); Engine.AddNode(parent); var child = new SpriteNode(); child.Texture = texture; child.Position = new Vector2F(120, 200); child.Src = new RectF(new Vector2F(), texture.Size); child.Pivot = new Vector2F(0.5f, 0.5f); child.AnchorMin = new Vector2F(0.2f, 0.0f); child.AnchorMax = new Vector2F(0.8f, 1f); child.ZOrder = 10; child.Mode = DrawMode.Fill; child.AdjustSize(); parent.AddChildNode(child); var childText = new TextNode(); childText.Font = font; childText.Color = new Color(0, 0, 0); childText.Text = "あいうえお"; childText.Pivot = new Vector2F(0.5f, 0.5f); childText.AnchorMin = new Vector2F(0.5f, 0.5f); childText.AnchorMax = new Vector2F(0.5f, 0.5f); childText.ZOrder = 15; childText.HorizontalAlignment = HorizontalAlignment.Center; childText.VerticalAlignment = VerticalAlignment.Center; childText.Size = child.Size; child.AddChildNode(childText); var text = new TextNode() { Font = font, Text = "", ZOrder = 10 }; Engine.AddNode(text); tc.Duration = 10000; tc.LoopBody(c => { if (Engine.Keyboard.GetKeyState(Keys.Right) == ButtonState.Hold) { rectSize.X += 1.5f; } if (Engine.Keyboard.GetKeyState(Keys.Left) == ButtonState.Hold) { rectSize.X -= 1.5f; } if (Engine.Keyboard.GetKeyState(Keys.Down) == ButtonState.Hold) { rectSize.Y += 1.5f; } if (Engine.Keyboard.GetKeyState(Keys.Up) == ButtonState.Hold) { rectSize.Y -= 1.5f; } if (Engine.Keyboard.GetKeyState(Keys.D) == ButtonState.Hold) { parent.Position += new Vector2F(1.5f, 0); } if (Engine.Keyboard.GetKeyState(Keys.A) == ButtonState.Hold) { parent.Position += new Vector2F(-1.5f, 0); } if (Engine.Keyboard.GetKeyState(Keys.S) == ButtonState.Hold) { parent.Position += new Vector2F(0, 1.5f); } if (Engine.Keyboard.GetKeyState(Keys.W) == ButtonState.Hold) { parent.Position += new Vector2F(0, -1.5f); } parent.SetVertexes(new[] { new Vector2F(0, 0), new Vector2F(rectSize.X, 0), new Vector2F(rectSize.X, rectSize.Y), new Vector2F(0, rectSize.Y), }, new Color(255, 255, 255, 255)); parent.AdjustSize(); text.Text = child.Size.ToString(); }, null); tc.End(); }
public void SpriteNode() { var tc = new TestCore(); tc.Init(); var texture = Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var node = new SpriteNode(); node.Src = new RectF(new Vector2F(100, 100), new Vector2F(200, 200)); node.Texture = texture; node.Pivot = new Vector2F(0.5f, 0.5f); node.AdjustSize(); Engine.AddNode(node); tc.LoopBody(c => { if (Engine.Keyboard.GetKeyState(Keys.Right) == ButtonState.Hold) { node.Position += new Vector2F(1.5f, 0); } if (Engine.Keyboard.GetKeyState(Keys.Left) == ButtonState.Hold) { node.Position -= new Vector2F(1.5f, 0); } if (Engine.Keyboard.GetKeyState(Keys.Down) == ButtonState.Hold) { node.Position += new Vector2F(0, 1.5f); } if (Engine.Keyboard.GetKeyState(Keys.Up) == ButtonState.Hold) { node.Position -= new Vector2F(0, 1.5f); } if (Engine.Keyboard.GetKeyState(Keys.B) == ButtonState.Hold) { node.Scale += new Vector2F(0.01f, 0.01f); } if (Engine.Keyboard.GetKeyState(Keys.S) == ButtonState.Hold) { node.Scale -= new Vector2F(0.01f, 0.01f); } if (Engine.Keyboard.GetKeyState(Keys.R) == ButtonState.Hold) { node.Angle += 3; } if (Engine.Keyboard.GetKeyState(Keys.L) == ButtonState.Hold) { node.Angle -= 3; } if (Engine.Keyboard.GetKeyState(Keys.X) == ButtonState.Hold) { node.Src = new RectF(node.Src.X, node.Src.Y, node.Src.Width - 2.0f, node.Src.Height - 2.0f); } if (Engine.Keyboard.GetKeyState(Keys.Z) == ButtonState.Hold) { node.Src = new RectF(node.Src.X, node.Src.Y, node.Src.Width + 2.0f, node.Src.Height + 2.0f); } if (Engine.Keyboard.GetKeyState(Keys.C) == ButtonState.Hold) { node.Src = new RectF(node.Src.X - 2.0f, node.Src.Y - 2.0f, node.Src.Width, node.Src.Height); } if (Engine.Keyboard.GetKeyState(Keys.V) == ButtonState.Hold) { node.Src = new RectF(node.Src.X + 2.0f, node.Src.Y + 2.0f, node.Src.Width, node.Src.Height); } } , null); tc.End(); }