示例#1
0
    public BunnyMark()
    {
        var player = Atomic.GetSubsystem <Player> ();

        player.LoadScene("Scenes/Scene.scene");
        scene = player.CurrentScene;

        SubscribeToEvent("Update", handleUpdate);
        SubscribeToEvent("MouseButtonDown", handleMouseButtonDown);
        SubscribeToEvent("MouseButtonUp", handleMouseButtonUp);

        var graphics = Atomic.GetSubsystem <Graphics> ();
        var cache    = Atomic.GetSubsystem <ResourceCache> ();

        halfWidth  = graphics.Width * pixelSize * 0.5f;
        halfHeight = graphics.Height * pixelSize * 0.5f;

        maxX = halfWidth;
        minX = -halfWidth;
        maxY = halfHeight;
        minY = -halfHeight;

        // TODO: generic version of this
        var sheet = (SpriteSheet2D)cache.GetResource("SpriteSheet2D", "Sprites/bunnys_sheet.xml");

        var bunny1 = sheet.GetSprite("bunny1");
        var bunny2 = sheet.GetSprite("bunny2");
        var bunny3 = sheet.GetSprite("bunny3");
        var bunny4 = sheet.GetSprite("bunny4");
        var bunny5 = sheet.GetSprite("bunny5");

        bunnyTextures = new Sprite2D[] { bunny1, bunny2, bunny3, bunny4, bunny5 };

        bunnyType      = 2;
        currentTexture = bunnyTextures [bunnyType];
    }