예제 #1
0
 public virtual void SetRegion(LTextureRegion region, int x, int y, int width,
                               int height)
 {
     texture = region.texture;
     SetRegion(region.GetRegionX() + x, region.GetRegionY() + y, width,
               height);
 }
예제 #2
0
        public static LTextureRegion[][] Split(LTexture texture, int tileWidth,
                                               int tileHeight)
        {
            LTextureRegion region = new LTextureRegion(texture);

            return(region.Split(tileWidth, tileHeight));
        }
예제 #3
0
		public LTextureRegion CreateTextureRegion(int id) {
			this.Pack();
			PackEntry entry = GetEntry(id);
			if (entry == null) {
				return null;
			}
			LTextureRegion region = new LTextureRegion(texture, entry.bounds.left,
					entry.bounds.top, entry.bounds.right, entry.bounds.bottom);
			return region;
		}
예제 #4
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);
		}
예제 #5
0
        public LTextureRegion CreateTextureRegion(int id)
        {
            this.Pack();
            PackEntry entry = GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            LTextureRegion region = new LTextureRegion(texture, entry.bounds.left,
                                                       entry.bounds.top, entry.bounds.right, entry.bounds.bottom);

            return(region);
        }
예제 #6
0
        public virtual LTextureRegion[][] Split(int tileWidth, int tileHeight)
        {
            int x      = GetRegionX();
            int y      = GetRegionY();
            int width  = GetRegionWidth();
            int height = GetRegionHeight();

            if (width < 0)
            {
                x     = x - width;
                width = -width;
            }

            if (height < 0)
            {
                y      = y - height;
                height = -height;
            }

            int rows = height / tileHeight;
            int cols = width / tileWidth;

            int startX = x;

            LTextureRegion[][] tiles = (LTextureRegion[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTextureRegion), rows, cols);
            for (int row = 0; row < rows; row++, y += tileHeight)
            {
                x = startX;
                for (int col = 0; col < cols; col++, x += tileWidth)
                {
                    tiles[row][col] = new LTextureRegion(texture, x, y, tileWidth,
                                                         tileHeight);
                }
            }

            return(tiles);
        }
예제 #7
0
 public virtual void SetRegion(LTextureRegion region)
 {
     texture = region.texture;
     SetRegion(region.xOff, region.yOff, region.widthRatio,
             region.heightRatio);
 }
예제 #8
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));
            }

            if (dpad != null) {
                dpad.Dispose();
                dpad = null;
            }
            if (buttons != null) {
                buttons.Dispose();
                buttons = null;
            }
            this.visible = true;

            this.SetLocation(0, 0);
        }
예제 #9
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);
 }
예제 #10
0
 public EmulatorButton(LTextureRegion img, int x, int y)
     : this(img, 0, 0, x, y, false)
 {
 }
예제 #11
0
 public LTextureRegion(LTextureRegion region, int x, int y, int width,
         int height)
 {
     SetRegion(region, x, y, width, height);
 }
예제 #12
0
 public static LTextureRegion[][] Split(LTexture texture, int tileWidth,
         int tileHeight)
 {
     LTextureRegion region = new LTextureRegion(texture);
     return region.Split(tileWidth, tileHeight);
 }
예제 #13
0
 public void Draw(LTextureRegion region, float x, float y)
 {
     Draw(region, x, y, region.GetRegionWidth(), region.GetRegionHeight());
 }
예제 #14
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);
 }
예제 #15
0
 public virtual void SetRegion(LTextureRegion region)
 {
     texture = region.texture;
     SetRegion(region.xOff, region.yOff, region.widthRatio,
               region.heightRatio);
 }
예제 #16
0
 public LTextureRegion(LTextureRegion region, int x, int y, int width,
                       int height)
 {
     SetRegion(region, x, y, width, height);
 }
예제 #17
0
 public LTextureRegion(LTextureRegion region)
 {
     SetRegion(region);
 }
예제 #18
0
 public EmulatorButton(LTextureRegion img, int w, int h, int x, int y)
     : this(img, w, h, x, y, true)
 {
 }
예제 #19
0
 public virtual void SetRegion(LTextureRegion region, int x, int y, int width,
         int height)
 {
     texture = region.texture;
     SetRegion(region.GetRegionX() + x, region.GetRegionY() + y, width,
             height);
 }
예제 #20
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());
 }
예제 #21
0
        public virtual LTextureRegion[][] Split(int tileWidth, int tileHeight)
        {
            int x = GetRegionX();
            int y = GetRegionY();
            int width = GetRegionWidth();
            int height = GetRegionHeight();

            if (width < 0)
            {
                x = x - width;
                width = -width;
            }

            if (height < 0)
            {
                y = y - height;
                height = -height;
            }

            int rows = height / tileHeight;
            int cols = width / tileWidth;

            int startX = x;
            LTextureRegion[][] tiles = (LTextureRegion[][])CollectionUtils.XNA_CreateJaggedArray(typeof(LTextureRegion), rows, cols);
            for (int row = 0; row < rows; row++, y += tileHeight)
            {
                x = startX;
                for (int col = 0; col < cols; col++, x += tileWidth)
                {
                    tiles[row][col] = new LTextureRegion(texture, x, y, tileWidth,
                            tileHeight);
                }
            }

            return tiles;
        }
예제 #22
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)
        {

            CheckTexture(region.GetTexture());

            float worldOriginX = x + originX;
            float worldOriginY = y + originY;
            float fx = -originX;
            float fy = -originY;
            float fx2 = width - originX;
            float fy2 = height - originY;

            if (scaleX != 1 || scaleY != 1)
            {
                fx *= scaleX;
                fy *= scaleY;
                fx2 *= scaleX;
                fy2 *= scaleY;
            }

            float p1x = fx;
            float p1y = fy;
            float p2x = fx;
            float p2y = fy2;
            float p3x = fx2;
            float p3y = fy2;
            float p4x = fx2;
            float p4y = fy;

            float x1;
            float y1;
            float x2;
            float y2;
            float x3;
            float y3;
            float x4;
            float y4;

            if (rotation != 0)
            {
                float cos = MathUtils.CosDeg(rotation);
                float sin = MathUtils.SinDeg(rotation);

                x1 = cos * p1x - sin * p1y;
                y1 = sin * p1x + cos * p1y;

                x2 = cos * p2x - sin * p2y;
                y2 = sin * p2x + cos * p2y;

                x3 = cos * p3x - sin * p3y;
                y3 = sin * p3x + cos * p3y;

                x4 = x1 + (x3 - x2);
                y4 = y3 - (y2 - y1);
            }
            else
            {
                x1 = p1x;
                y1 = p1y;

                x2 = p2x;
                y2 = p2y;

                x3 = p3x;
                y3 = p3y;

                x4 = p4x;
                y4 = p4y;
            }

            x1 += worldOriginX;
            y1 += worldOriginY;
            x2 += worldOriginX;
            y2 += worldOriginY;
            x3 += worldOriginX;
            y3 += worldOriginY;
            x4 += worldOriginX;
            y4 += worldOriginY;

            float u1, v1, u2, v2, u3, v3, u4, v4;
            if (clockwise)
            {
                u1 = region.widthRatio;
                v1 = region.heightRatio;
                u2 = region.xOff;
                v2 = region.heightRatio;
                u3 = region.xOff;
                v3 = region.yOff;
                u4 = region.widthRatio;
                v4 = region.yOff;
            }
            else
            {
                u1 = region.xOff;
                v1 = region.yOff;
                u2 = region.widthRatio;
                v2 = region.yOff;
                u3 = region.widthRatio;
                v3 = region.heightRatio;
                u4 = region.xOff;
                v4 = region.heightRatio;
            }

            vertices[idx].Position.X = x1;
            vertices[idx].Position.Y = y1;
            vertices[idx].Color = m_color;
            vertices[idx].TextureCoordinate.X = u1;
            vertices[idx].TextureCoordinate.Y = v1;

            vertices[idx + 1].Position.X = x2;
            vertices[idx + 1].Position.Y = y2;
            vertices[idx + 1].Color = m_color;
            vertices[idx + 1].TextureCoordinate.X = u2;
            vertices[idx + 1].TextureCoordinate.Y = v2;

            vertices[idx + 2].Position.X = x3;
            vertices[idx + 2].Position.Y = y3;
            vertices[idx + 2].Color = m_color;
            vertices[idx + 2].TextureCoordinate.X = u3;
            vertices[idx + 2].TextureCoordinate.Y = v3;

            vertices[idx + 3].Position.X = x4;
            vertices[idx + 3].Position.Y = y4;
            vertices[idx + 3].Color = m_color;
            vertices[idx + 3].TextureCoordinate.X = u4;
            vertices[idx + 3].TextureCoordinate.Y = v4;

            idx += 4;
        }
예제 #23
0
 public LTextureRegion(LTextureRegion region)
 {
     SetRegion(region);
 }
예제 #24
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);
 }
예제 #25
0
        public void Draw(LTextureRegion region, float x, float y, float width,
                float height)
        {
            CheckTexture(region.GetTexture());

            float fx2 = x + width;
            float fy2 = y + height;
            float u = region.xOff;
            float v = region.yOff;
            float u2 = region.widthRatio;
            float v2 = region.heightRatio;

            vertices[idx].Position.X = x;
            vertices[idx].Position.Y = y;
            vertices[idx].Color = m_color;
            vertices[idx].TextureCoordinate.X = u;
            vertices[idx].TextureCoordinate.Y = v;

            vertices[idx + 1].Position.X = x;
            vertices[idx + 1].Position.Y = fy2;
            vertices[idx + 1].Color = m_color;
            vertices[idx + 1].TextureCoordinate.X = u;
            vertices[idx + 1].TextureCoordinate.Y = v2;

            vertices[idx + 2].Position.X = fx2;
            vertices[idx + 2].Position.Y = fy2;
            vertices[idx + 2].Color = m_color;
            vertices[idx + 2].TextureCoordinate.X = u2;
            vertices[idx + 2].TextureCoordinate.Y = v2;

            vertices[idx + 3].Position.X = fx2;
            vertices[idx + 3].Position.Y = y;
            vertices[idx + 3].Color = m_color;
            vertices[idx + 3].TextureCoordinate.X = u2;
            vertices[idx + 3].TextureCoordinate.Y = v;

            idx += 4;
        }
예제 #26
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())
        {
        }