Пример #1
0
        private void CreateDemo1(SkeletonDefinition skeletonDefinition)
        {
            _cameraZoom = 1f;

            // shows four running guys with different depths to show layering of sprites.
            // the second is most in front, 1 and 3 are behind that, and 4th is furthest

            _poseRuntime.Add(skeletonDefinition.CreateInstance(new Vector2(-100, 0), 1, 0));
            _poseRuntime.Add(skeletonDefinition.CreateInstance(new Vector2(0, 0), 0, 0));
            _poseRuntime.Add(skeletonDefinition.CreateInstance(new Vector2(100, 0), 1, 0));
            _poseRuntime.Add(skeletonDefinition.CreateInstance(new Vector2(200, 0), 2, 0));
        }
Пример #2
0
        private void CreateDemo2(SkeletonDefinition skeletonDefinition)
        {
            // this shows a lot of running guys in a grid with random rotations. It's to test performance and try out potential improvements of the runtime logic.
            // for detailed performance measuring, I suggest using JetBrains' profiler in Line-by-Line mode.

            _cameraZoom = 0.3f;
            var       r          = new Random();
            const int count      = 5000;
            var       horizCount = (int)(MathF.Sqrt(count) * 1.3f);
            var       vertCount  = count / horizCount + 1;
            const int distance   = 100;

            for (var i = 0; i < count; i++)
            {
                var position = new Vector2(i % horizCount - horizCount / 2, i / horizCount - vertCount / 2) * distance;
                _poseRuntime.Add(skeletonDefinition.CreateInstance(position, 0, (float)r.NextDouble() * 6.283f));
            }
        }