Пример #1
0
    public static void TestAddRemove()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dRenderObject renderObject = new Roga2dRenderObject(null, new Vector2(64, 64), new Vector2(32, 16), new Rect(0, 0, 1, 1));
        Roga2dSprite sprite = new Roga2dSprite(renderObject);

        Tester.Match(node.ChildrenCount, 0);

        node.AddChild(sprite);
        Tester.Match(node.ChildrenCount, 1);
        node.Update();

        node.RemoveAllChildren();
        Tester.Match(node.ChildrenCount, 0);

        node.Destroy();
    }
Пример #2
0
    public static void TestUpdate()
    {
        Roga2dNode node = new Roga2dNode();
        Roga2dNode child = new Roga2dNode();

        node.LocalAlpha = 0.3f;
        node.LocalPriority = 0.4f;
        node.LocalPosition = new Vector2(1.0f, 2.0f);
        node.LocalRotation = 3.0f;
        node.LocalScale = new Vector2(-1.0f, -2.0f);

        child.LocalAlpha = 0.3f;
        child.LocalPriority = 0.4f;
        node.AddChild(child);

        // Before transform
        Tester.Match(node.Alpha, 1.0f);
        Tester.Match(node.Priority, -999.0f);
        Tester.Match(child.Alpha, 1.0f);
        Tester.Match(child.Priority, -999.0f);

        node.Update();
        // After transform
        Tester.Match(node.Transform.localPosition, new Vector3(1.0f, 2.0f, 0.4f));
        Tester.Match(node.Transform.localEulerAngles, new Vector3(0.0f, 0.0f, 3.0f));
        Tester.Match(node.Transform.localScale, new Vector3(-1.0f, -2.0f, 1.0f));
        Tester.Match(node.Transform, child.Transform.parent);
        Tester.Match(node.Alpha, 0.3f);
        Tester.Match(node.Priority, 0.4f);
        Tester.Match(child.Alpha, 0.09f);
        Tester.Match(child.Priority, 0.8f);

        node.Destroy();
    }