Exemple #1
0
 public SpriteRegion(LTextureRegion region, int srcX, int srcY,
                     int srcWidth, int srcHeight)
 {
     SetRegion(region, srcX, srcY, srcWidth, srcHeight);
     SetColor(1f, 1f, 1f, 1f);
     setSize(Math.Abs(srcWidth), Math.Abs(srcHeight));
     setOrigin(width / 2, height / 2);
 }
Exemple #2
0
 public SpriteRegion(LTextureRegion region)
 {
     SetRegion(region);
     SetColor(1f, 1f, 1f, 1f);
     setSize(Math.Abs(region.GetRegionWidth()),
             Math.Abs(region.GetRegionHeight()));
     setOrigin(width / 2, height / 2);
 }
Exemple #3
0
        public void Draw(LTextureRegion region, float x, float y, float rotation)
        {
            if (isClose)
            {
                return;
            }
            if (region == null)
            {
                return;
            }
            LTexture texture = region.texture;

            if (texture == null)
            {
                return;
            }

            if (!texture.isLoaded)
            {
                texture.LoadTexture();
            }

            float xOff        = region.xOff;
            float yOff        = region.yOff;
            float widthRatio  = region.widthRatio;
            float heightRatio = region.heightRatio;

            texDst.X      = (int)x;
            texDst.Y      = (int)y;
            texDst.Width  = region.GetRegionWidth();
            texDst.Height = region.GetRegionHeight();
            texSrc.X      = region.dstX;
            texSrc.Y      = region.dstY;
            texSrc.Width  = region.dstWidth;
            texSrc.Height = region.dstHeight;

            Load(texture);

            if (rotation != 0)
            {
                float centerX = texSrc.Width / 2;
                float centerY = texSrc.Height / 2;
                texDst.X += (int)texture.Width / 2;
                texDst.Y += (int)texture.Height / 2;
                origin.X  = centerX;
                origin.Y  = centerY;
                batch.Draw(texture, texDst, texSrc, color, MathUtils.ToRadians(rotation), origin, SpriteEffects.None, 0);
            }
            else
            {
                batch.Draw(texture, texDst, texSrc, color);
            }
            idx++;
        }
Exemple #4
0
 public void SetClickImage(LTexture on)
 {
     if (on == null)
     {
         return;
     }
     if (bitmap != null)
     {
         bitmap.Dispose();
     }
     this.bitmap = new LTextureRegion(on);
     this.SetSize(on.GetWidth(), on.GetHeight());
 }
Exemple #5
0
 public EmulatorButton(LTextureRegion img, int w, int h, int x, int y,
                       bool flag, int sizew, int sizeh)
 {
     if (flag)
     {
         this.bitmap = new LTextureRegion(img, x, y, w, h);
     }
     else
     {
         this.bitmap = new LTextureRegion(img);
     }
     this.scaleWidth  = sizew;
     this.scaleHeight = sizeh;
     this.bounds      = new RectBox(0, 0, scaleWidth, scaleHeight);
 }
Exemple #6
0
        public void Draw(LTextureRegion region, float x, float y, float originX,
                         float originY, float width, float height, float scaleX,
                         float scaleY, float rotation, bool clockwise)
        {
            if (isClose)
            {
                return;
            }
            if (region == null)
            {
                return;
            }
            LTexture texture = region.texture;

            if (texture == null)
            {
                return;
            }

            if (!texture.isLoaded)
            {
                texture.LoadTexture();
            }

            float xOff        = region.xOff;
            float yOff        = region.yOff;
            float widthRatio  = region.widthRatio;
            float heightRatio = region.heightRatio;

            texDst.X      = (int)x;
            texDst.Y      = (int)y;
            texDst.Width  = (int)(width * scaleX);
            texDst.Height = (int)(height * scaleY);
            texSrc.X      = region.dstX;
            texSrc.Y      = region.dstY;
            texSrc.Width  = region.dstWidth;
            texSrc.Height = region.dstHeight;

            Load(texture);

            if (rotation != 0)
            {
                float centerX = texSrc.Width / 2;
                float centerY = texSrc.Height / 2;
                texDst.X += (int)texDst.Width / 2;
                texDst.Y += (int)texDst.Height / 2;
                origin.X  = centerX;
                origin.Y  = centerY;
                batch.Draw(texture.Texture, texDst, texSrc, color, MathUtils.ToRadians(rotation), origin, SpriteEffects.None, 0);
            }
            else if (originX != 0 || originX != 0)
            {
                texDst.X += (int)originX;
                texDst.Y += (int)originY;
                origin.X  = originX;
                origin.Y  = originY;
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, origin, SpriteEffects.None, 0);
            }
            else
            {
                batch.Draw(texture.Texture, texDst, texSrc, color, 0, Vector2.Zero, SpriteEffects.None, 0);
            }
            idx++;
        }
Exemple #7
0
 public void Draw(LTextureRegion region, float x, float y, float originX,
                  float originY, float width, float height, float scaleX,
                  float scaleY, float rotation)
 {
     Draw(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation);
 }
Exemple #8
0
 public void Draw(LTextureRegion region, float x, float y, float width,
                  float height, float rotation)
 {
     Draw(region, x, y, region.GetRegionWidth() / 2,
          region.GetRegionHeight() / 2, width, height, 1f, 1f, rotation);
 }
Exemple #9
0
 public void Draw(LTextureRegion region, float x, float y)
 {
     Draw(region, x, y, 0);
 }
Exemple #10
0
        public EmulatorButtons(EmulatorListener el, int w, int h, float scale)
        {
            this.emulatorListener = el;
            if (pack == null)
            {
                pack = new LTexturePack();
                pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e1.png"));
                pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e2.png"));
                pack.Pack(Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR);
            }
            RectBox.Rect2i bounds = pack.GetEntry(0).getBounds();
            this.dpad = new LTextureRegion(pack.GetTexture(), bounds.left,
                                           bounds.top, bounds.right, bounds.bottom);
            bounds       = pack.GetEntry(1).getBounds();
            this.buttons = new LTextureRegion(pack.GetTexture(), bounds.left,
                                              bounds.top, bounds.right, bounds.bottom);
            this.width  = w;
            this.height = h;

            if (scale <= 0f)
            {
                this.up    = new EmulatorButton(dpad, 40, 40, 40, 0, true, 60, 60);
                this.left  = new EmulatorButton(dpad, 40, 40, 0, 40, true, 60, 60);
                this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, 60, 60);
                this.down  = new EmulatorButton(dpad, 40, 40, 40, 80, true, 60, 60);

                this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true,
                                                   68, 68);
                this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, 68,
                                                 68);
                this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, 68,
                                                 68);
                this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, 68,
                                                 68);
            }
            else
            {
                this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true,
                                             (int)(60 * scale), (int)(60 * scale));
                this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true,
                                               (int)(60 * scale), (int)(60 * scale));
                this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true,
                                                (int)(60 * scale), (int)(60 * scale));
                this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true,
                                               (int)(60 * scale), (int)(60 * scale));

                this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true,
                                                   (int)(68 * scale), (int)(68 * scale));
                this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true,
                                                 (int)(68 * scale), (int)(68 * scale));
                this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true,
                                                 (int)(68 * scale), (int)(68 * scale));
                this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true,
                                                 (int)(68 * scale), (int)(68 * scale));
            }

            this.up._monitor       = new up_monitor(el);
            this.left._monitor     = new left_monitor(el);
            this.right._monitor    = new right_monitor(el);
            this.down._monitor     = new down_monitor(el);
            this.triangle._monitor = new triangle_monitor(el);
            this.square._monitor   = new square_monitor(el);
            this.circle._monitor   = new circle_monitor(el);
            this.cancel._monitor   = new cancel_monitor(el);
            if (dpad != null)
            {
                dpad.Dispose();
                dpad = null;
            }
            if (buttons != null)
            {
                buttons.Dispose();
                buttons = null;
            }
            this.visible = true;

            this.SetLocation(0, 0);
        }
Exemple #11
0
 public EmulatorButton(LTextureRegion img, int w, int h, int x, int y,
                       bool flag) : this(img, w, h, x, y, flag, img.GetRegionWidth(), img.GetRegionHeight())
 {
 }
Exemple #12
0
 public EmulatorButton(LTextureRegion img, int x, int y) : this(img, 0, 0, x, y, false)
 {
 }
Exemple #13
0
 public EmulatorButton(LTextureRegion img, int w, int h, int x, int y) : this(img, w, h, x, y, true)
 {
 }