merge setPosition and focusOn into setViewport

This commit is contained in:
Hanusiak Piotr 2022-01-13 16:08:16 +01:00
parent a1c96b0524
commit d62b116e5d
9 changed files with 44 additions and 116 deletions

View file

@ -51,32 +51,14 @@
{
"fontfamily":"MS Shell Dlg 2",
"pixelsize":21,
"text":"Set Position - Move the camera to the given point but do not lock it. If the player moves, camera will back to following him",
"text":"Set Viewport - Move the camera to the given point. It will be locked if Lock checkbox is checked",
"wrap":true
},
"type":"",
"visible":true,
"width":315.4375,
"x":68.4021076998051,
"y":8.73391812865529
},
{
"height":115.776,
"id":3,
"name":"",
"rotation":0,
"text":
{
"fontfamily":"MS Shell Dlg 2",
"pixelsize":21,
"text":"Focus On - Works like for Focusable Zones. Camera will be locked and won't move unless we explicitly change the mode",
"wrap":true
},
"type":"",
"visible":true,
"width":315.438,
"x":64.7309301350722,
"y":126.555409408477
"y":160.73391812865529
},
{
"height":115.776,
@ -95,24 +77,6 @@
"width":315.438,
"x":64.7309301350722,
"y":256.224715416861
},
{
"height":115.776,
"id":5,
"name":"",
"rotation":0,
"text":
{
"fontfamily":"MS Shell Dlg 2",
"pixelsize":21,
"text":"Both Set Position and Focus On will lock the ability of changing the game zoom",
"wrap":true
},
"type":"",
"visible":true,
"width":315.438,
"x":65.848768979972,
"y":351.241017233349
}],
"opacity":1,
"type":"objectgroup",

View file

@ -8,33 +8,22 @@
WA.camera.onCameraUpdate((worldView) => console.log(worldView));
WA.onInit().then(() => {
console.log('After WA init');
const setPositionButton = document.getElementById('setPositionButton');
const focusOnButton = document.getElementById('focusOnButton');
const setViewportButton = document.getElementById('setViewportButton');
const followPlayerButton = document.getElementById('followPlayerButton');
const xField = document.getElementById('x');
const yField = document.getElementById('y');
const widthField = document.getElementById('width');
const heightField = document.getElementById('height');
const smoothField = document.getElementById('smooth');
const lockField = document.getElementById('lock');
setPositionButton.addEventListener('click', () => {
console.log('SET POSITION BUTTON PRESSED');
console.log(smoothField.checked);
WA.camera.setPosition(
parseInt(xField.value),
parseInt(yField.value),
parseInt(widthField.value),
parseInt(heightField.value),
smoothField.checked,
);
});
focusOnButton.addEventListener('click', () => {
WA.camera.focusOn(
setViewportButton.addEventListener('click', () => {
WA.camera.setViewport(
parseInt(xField.value),
parseInt(yField.value),
parseInt(widthField.value),
parseInt(heightField.value),
lockField.checked,
smoothField.checked,
);
});
@ -52,9 +41,9 @@ Y: <input type="text" id="y" value="64" /><br/>
width: <input type="text" id="width" value="600" /><br/>
height: <input type="text" id="height" value="400" /><br/>
Smooth: <input type="checkbox" id="smooth" value=1 /><br/>
Lock: <input type="checkbox" id="lock" value=1 /><br/>
<button id="setPositionButton">Set Position</button>
<button id="focusOnButton">Focus On</button>
<button id="setViewportButton">Set Viewport</button>
<button id="followPlayerButton">Follow Player</button>
</body>