mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
fix clipping
This commit is contained in:
parent
a548b15d69
commit
e64082a609
3 changed files with 17 additions and 7 deletions
|
|
@ -119,7 +119,7 @@ class GuiControl {
|
||||||
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
|
rect.position = parentRect.position.add(this.position.multiply(uiScaleFactor));
|
||||||
}
|
}
|
||||||
|
|
||||||
var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio;
|
var scaleFactor = 1.0;
|
||||||
#if (js || android)
|
#if (js || android)
|
||||||
scaleFactor = 1 / Settings.zoomRatio; // 768 / js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio; // 0.5; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
|
scaleFactor = 1 / Settings.zoomRatio; // 768 / js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio; // 0.5; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768;
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import src.MarbleGame;
|
||||||
@:publicFields
|
@:publicFields
|
||||||
class GuiImage extends GuiControl {
|
class GuiImage extends GuiControl {
|
||||||
var bmp:Bitmap;
|
var bmp:Bitmap;
|
||||||
|
var bmpFlow:Flow;
|
||||||
|
|
||||||
public var pressedAction:GuiControl->Void = null;
|
public var pressedAction:GuiControl->Void = null;
|
||||||
|
|
||||||
|
|
@ -24,16 +25,23 @@ class GuiImage extends GuiControl {
|
||||||
// bmp.scaleY = renderRect.extent.y / bmp.tile.height;
|
// bmp.scaleY = renderRect.extent.y / bmp.tile.height;
|
||||||
bmp.width = renderRect.extent.x;
|
bmp.width = renderRect.extent.x;
|
||||||
bmp.height = renderRect.extent.y;
|
bmp.height = renderRect.extent.y;
|
||||||
if (scene2d.contains(bmp)) {
|
if (doClipping) {
|
||||||
scene2d.removeChild(bmp); // Refresh "layer"
|
bmpFlow.maxWidth = Std.int(hittestRect.extent.x);
|
||||||
|
bmpFlow.maxHeight = Std.int(hittestRect.extent.y);
|
||||||
}
|
}
|
||||||
scene2d.addChild(bmp);
|
if (scene2d.contains(obj)) {
|
||||||
|
scene2d.removeChild(obj); // Refresh "layer"
|
||||||
|
}
|
||||||
|
scene2d.addChild(obj);
|
||||||
super.render(scene2d);
|
super.render(scene2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function dispose() {
|
public override function dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
this.bmp.remove();
|
if (this.doClipping) {
|
||||||
|
bmpFlow.remove();
|
||||||
|
} else
|
||||||
|
this.bmp.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override function onMouseRelease(mouseState:MouseState) {
|
public override function onMouseRelease(mouseState:MouseState) {
|
||||||
|
|
@ -45,6 +53,9 @@ class GuiImage extends GuiControl {
|
||||||
|
|
||||||
public override function onRemove() {
|
public override function onRemove() {
|
||||||
super.onRemove();
|
super.onRemove();
|
||||||
|
if (MarbleGame.canvas.scene2d.contains(bmpFlow)) {
|
||||||
|
MarbleGame.canvas.scene2d.removeChild(bmpFlow); // Refresh "layer"
|
||||||
|
}
|
||||||
if (MarbleGame.canvas.scene2d.contains(bmp)) {
|
if (MarbleGame.canvas.scene2d.contains(bmp)) {
|
||||||
MarbleGame.canvas.scene2d.removeChild(bmp); // Refresh "layer"
|
MarbleGame.canvas.scene2d.removeChild(bmp); // Refresh "layer"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ class Rect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function inRect(point:Vector) {
|
public function inRect(point:Vector) {
|
||||||
return (position.x <= point.x && (position.x + extent.x) >= point.x)
|
return (position.x < point.x && (position.x + extent.x) > point.x) && (position.y < point.y && (position.y + extent.y) > point.y);
|
||||||
&& (position.y <= point.y && (position.y + extent.y) >= point.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function intersect(other:Rect) {
|
public function intersect(other:Rect) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue