Hi guys
I’m trying to implement viewport on my game to make it keep on aspect ratio.
I set my scene scale mode to letter box and get black area (pillar box/letter box) when the window get scale.
the problem is if there is part of a bitap inside letter box (outside the scene area I guess…), it still get rendered. I believe it shouldn’t get rendered
I tried to add camera and enable camera clip hoping it will restrict render area but it still get rendered.
Im a missing something or doing something wrong?
import hxd.Window;
import hxd.Res;
import h2d.Object;
import h2d.Bitmap;
import h2d.Graphics;
import h2d.Tile;
import h2d.Scene;
import h2d.Camera;
class Main extends hxd.App{
var window:Window;
var min_window_width = 1280;
var min_window_height = 720;
var graphics:Graphics;
var camera:Camera;
override function init(){
super.init();
hxd.Res.initEmbed();
// set window
window = Window.getInstance();
window.resize(min_window_width, min_window_height);
// set scale mode
// integerScale = false for viewport scale
s2d.scaleMode = LetterBox(min_window_width, min_window_height, false, Center, Center);
camera = new Camera(s2d);
camera.setViewport(min_window_width, min_window_height, 0, 0);
camera.clipViewport = true;
graphics = new Graphics(s2d);
// draw background
graphics.beginFill(0x808080);
graphics.drawRect(0, 0, min_window_width, min_window_height);
var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
tf.text = "hello world!";
var image_tile = Res.images.haxe_logo_wh.toTile();
var bmp = new Bitmap(image_tile, s2d);
bmp.x = -100;
bmp.y = 100;
}
override function update(dt:Float){
}
static function main(){
new Main();
}
}