rgui
Version:
RPG Maker MV GUI framework.
106 lines (89 loc) • 2.47 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Base</title>
</head>
<body style="background-color: black; margin: 0;">
<script>
let ipcRenderer = require('electron').ipcRenderer;
ipcRenderer.send('show-dev');
const LoadManager = require('../src/loadManager');
LoadManager.pathDir += '/res/';
require('../src/lib/pixi');
const RGUI = require('../src/rgui');
const Bitmap = require('./js/bitmap');
const Sprite = require('./js/sprite');
const Input = RGUI.Input;
let renderer = PIXI.autoDetectRenderer(1280, 720, {backgroundColor : 0x000000, resolution: 1});
document.body.appendChild(renderer.view);
RGUI.init();
function scaleToWindow (view) {
view.style.position = "absolute";
view.style.width = window.innerWidth + "px";
view.style.height = window.innerHeight + "px";
view.style.display = "block";
}
scaleToWindow(renderer.view);
window.addEventListener('resize', () => { scaleToWindow(renderer.view) });
let stage = new PIXI.Container();
ipcRenderer.send('show-dev');
let bg = new RGUI.ImageBox({
x: 0,
y: 0,
width: 1280,
height: 720,
type: 0,
focus: true,
image: 'bg'
});
let image = new RGUI.ImageBox({
x: 100,
y: 100,
width: 400,
height: 400,
type: 0,
focus: true,
image: 'test'
});
image.eventManager.on('A', {}, ()=>{ image.x -= 10 });
image.eventManager.on('D', {}, ()=>{ image.x += 10 });
image.eventManager.on('W', {}, ()=>{ image.y -= 10 });
image.eventManager.on('S', {}, ()=>{ image.y += 10 });
image.eventManager.on('changeX', {}, ()=>{
if(image.x < 0 ) image.x = 0;
if(image.x > 1280 - image.width) image.x = 1280 - image.width
});
image.eventManager.on('changeY', {}, ()=>{
if(image.y < 0 ) image.y = 0;
if(image.y > 720 - image.height) image.y = 720 - image.height
});
let button = new RGUI.Button({
x: 30,
y: 168,
width: 158,
height: 60,
text: '人物'
});
button.eventManager.on('click', {}, function () {
image.type = image.type == 1 ? 0 : 1;
});
stage.addChild(bg);
stage.addChild(image);
stage.addChild(button);
animate();
function animate() {
requestAnimationFrame(animate);
if(Input.keyDown('F10')) {
ipcRenderer.send('show-dev');
Input.clear()
}
bg.update();
button.update();
image.update();
renderer.render(stage);
Input.update();
}
</script>
</body>
</html>