Exemple #1
0
        public MCBaseSprite CreateSpriteFromTextureName(string name, float anchorX = float.MinValue, float anchorY = float.MinValue)
        {
            string spriteName;
            //---------------------------------------------
            //! テクスチャースの読み込み
            //---------------------------------------------
            MCBaseTexture baseTx;

            if (!App.ImageMgr.GetTexture(name, out baseTx))
            {
                baseTx = MCTexture.CreateTextureFromFile(
                    App,
                    name,
                    name
                    );
                if (baseTx == null)
                {
                    throw new Exception("スプライト作成で、テキストテクスチャ[" + name + "]からテクスチャ作成失敗しました。");
                }
            }
            int w = baseTx.GetDesc().D2.Width;
            int h = baseTx.GetDesc().D2.Height;

            spriteName = CreateName(name, 0, 0, w, h, anchorX, anchorY);

            MCTexture tx = (MCTexture)baseTx;
            //---------------------------------------------
            //! スプライト登録
            //---------------------------------------------
            MCBaseSprite spriteData;

            if (!App.SpriteMgr.GetSpriteData(spriteName, out spriteData))
            {
                MCSprite sp;
                MCRect   rc = new MCRect();

                bool ret;
                rc.SetXYWH(0, 0, w, h);

                if (anchorX == float.MinValue && anchorY == float.MinValue)
                {
                    sp = MCSprite.CreateSprite(App, spriteName, baseTx, rc, MC_SPRITE_ANCHOR.CENTER);
                }
                else
                {
                    sp = MCSprite.CreateSprite(App, spriteName, baseTx, rc, MC_SPRITE_ANCHOR.CUSTOM, anchorX, anchorY);
                }

                if (sp == null)
                {
                    throw new Exception("スプライト作成失敗[" + spriteName + "]既に登録されている名前か、それ以外です。");
                }
                spriteData = sp;
            }

            m_spriteMgr.Add(spriteData, true);
            return(spriteData);
        }
        public MCBaseSprite CreateAlphanumericSprite(string name, int w, int h, MC_ANC useFlgsANC)
        {
            string spriteName;

            //---------------------------------------------
            //! テクスチャースの読み込み
            //---------------------------------------------
            MCBaseTexture txISP;
            string        str = "";

            if (!App.ImageMgr.GetTexture(name, out txISP))
            {
                txISP = MCTexture.CreateTextureFromFile(
                    App,
                    name,
                    name
                    );

                if (txISP == null)
                {
                    str = "スプライト作成で、テキストテクスチャ[" + name + "]からテクスチャ作成失敗しました。";
                    throw new Exception(str);
                }
            }

            MCTexture txSP = (MCTexture)txISP;

            str = "Alphanumericプライト作成で、2Dテクスチャでないテクスチャーを取得した。";
            Trace.WriteLine(str);
            return(null);

            //
            {
                str        = name + "_" + w + "_" + h + "_" + useFlgsANC;
                spriteName = str;
            }

            //---------------------------------------------
            //! スプライト登録
            //---------------------------------------------
            MCBaseSprite spriteData;

            if (!App.SpriteMgr.GetSpriteData(spriteName, out spriteData))
            {
                MCAlphanumericSprite sp;

                if ((sp = MCAlphanumericSprite.CreateSprite(App, spriteName, txISP, w, h, useFlgsANC)) == null)
                {
                    throw new Exception("固定英数字プライト作成失敗[" + spriteName + "]。");
                }

                spriteData = sp;
            }

            m_spriteMgr.Add(spriteData, true);
            return(spriteData);
        }
Exemple #3
0
        /// <summary>
        /// デバイス作成時の処理
        /// </summary>
        /// <returns></returns>
        internal int OnCreateDevice(SharpDX.Direct3D11.Device device)
        {
            MCBaseTexture tmpTx;

            //---- イメージの読み込み
            if (!App.ImageMgr.GetTexture("AsciiStringDraw", out tmpTx))
            {
                m_asciiTx = (MCTexture)MCTexture.CreateTextureFromFile(
                    App,
                    "AsciiStringDraw",
                    "UtilSharpDX.Resources.ascii.png"
                    );
                if (m_asciiTx == null)
                {
                    throw new Exception();
                }
            }
            else
            {
                throw new Exception();
            }
            //----
            MCBaseSprite tmpSprite;

            if (!App.SpriteMgr.GetSpriteData("AsciiStringDraw", out tmpSprite))
            {
                m_asciiSprite = MCAlphanumericSprite.CreateSprite(
                    App,
                    "AsciiStringDraw",
                    m_asciiTx,
                    12, 12,
                    MC_ANC.STR_ALL
                    );
                if (m_asciiSprite == null)
                {
                    throw new Exception();
                }
            }
            else
            {
                throw new Exception();
            }
            return(0);
        }