Пример #1
0
        public static ImageAsset MakeColorImage(uint rSizeX, uint rSizeY, uint rColor1, uint rColor2, uint rColor3, uint rColor4, int rFill)
        {
            string tName = rSizeX.ToString() + "," + rSizeY.ToString() + "," + rColor1.ToString() + "," + rColor2.ToString() + "," + rColor3.ToString() + "," + rColor4.ToString() + "," + rFill.ToString();

            var tImg = Media.GetImageAsset(tName, 1.0f, 1.0f);

            if (tImg != null)
            {
                return(tImg);
            }

            Agk.Swap();
            Agk.DrawBox(0, 0, rSizeX, rSizeY, rColor1, rColor2, rColor3, rColor4, rFill);
            Agk.Render();
            var tNum = Agk.GetImage(0, 0, rSizeX, rSizeY);

            Agk.ClearScreen();
            Agk.Swap();

            App.Log("Media.cs", 2, "media", " > made image from color");

            tImg = new ImageAsset()
            {
                ResourceNumber = tNum,
                File           = tName,
                ScaleX         = 1.0f,
                ScaleY         = 1.0f
            };
            Media.ImageList.Add(tImg);
            return(tImg);
        }
Пример #2
0
        public CharacterEntity2d(string rFileBase, int rWidth, int rHeight)
        {
            Properties.IsObject = false;
            Properties.Filebase = rFileBase;

            ImageAsset tSheet = Media.GetImageAsset(rFileBase + ".png", 1.0f, 1.0f);

            Agk.Swap();
            var spSheet = Agk.CreateSprite(tSheet.ResourceNumber);

            Agk.SetSpritePosition(spSheet, 0.0f, 0.0f);
            Agk.Render();
            bool isFirst = true;

            for (int row = 0; row < (Agk.GetImageHeight(tSheet.ResourceNumber) / rHeight); row++)
            {
                for (int col = 0; col < (Agk.GetImageWidth(tSheet.ResourceNumber) / rWidth); col++)
                {
                    var tImg = Agk.GetImage(col * rWidth, row * rHeight, rWidth, rHeight);
                    if (isFirst)
                    {
                        Properties.ResourceNumber = Agk.CreateSprite(tImg);
                        isFirst = false;
                    }
                    Agk.AddSpriteAnimationFrame(Properties.ResourceNumber, tImg);
                }
            }
            Agk.DeleteSprite(spSheet);
            Agk.ClearScreen();
            Agk.Swap();

            CharacterHandler2d.CharacterList.Add(this);
        }