Every built-in JVL class, with the methods you'll actually use and a runnable example for each. For the language rules themselves (classes, events, named parameters) see the Wiki.
A minimal moving-and-shooting player, entirely in JVL:
class Main {
VJObject player;
@onStart
void setup() {
player = VJObject.rect("player", 0, 0, 40, 40, Color.CYAN);
Physics.gravity(0, 0.6);
}
@onUpdate
void loop() {
if (KEY_LEFT) player.moveX(-4);
if (KEY_RIGHT) player.moveX(4);
if (KEY_SPACE) player.rotate(5);
}
void Main(String[] args) {
System.print("Game started.");
}
}
Reading and writing a save file:
Config.write("resources/save.cfg", "highscore", 4200);
int best = Config.readInt("resources/save.cfg", "highscore", 0);
System.print("Best score: " + best);
Un player minimo che si muove e "spara", interamente in JVL:
class Main {
VJObject player;
@onStart
void setup() {
player = VJObject.rect("player", 0, 0, 40, 40, Color.CYAN);
Physics.gravity(0, 0.6);
}
@onUpdate
void loop() {
if (KEY_LEFT) player.moveX(-4);
if (KEY_RIGHT) player.moveX(4);
if (KEY_SPACE) player.rotate(5);
}
void Main(String[] args) {
System.print("Game started.");
}
}
Leggere e scrivere un file di salvataggio:
Config.write("resources/save.cfg", "highscore", 4200);
int best = Config.readInt("resources/save.cfg", "highscore", 0);
System.print("Best score: " + best);
The base type for anything drawn in a 2D scene: rectangles, circles, triangles and images. Created with a factory method, loaded from a saved scene, or read back with Scene.find(...).
VJObject player = VJObject.rect("player", 100, 300, 40, 40, Color.CYAN);
VJObject e = VJObject.circle("enemy", 500, 300, 40, Color.RED);
VJObject loaded = VJObject.load("player", "resources/vj/player.vj");
VJObject byName = Scene.find("player");
| Method | Description |
|---|---|
VJObject.rect(name, x, y, w, h, color) | Creates a rectangle at (x, y) and adds it to the running scene. |
VJObject.circle(name, x, y, diameter, color) | Creates a circle. |
VJObject.create(name, shape, x, y, w, h, color) | Generic factory; shape is one of the Shape constants. |
VJObject.createImage(name, path, x, y, w, h) | Creates an image-backed object from a file under resources. |
VJObject.load(name, resourcePath) | Loads transform/color/texture from a .vj file saved by the Scene Editor. |
| Method | Description |
|---|---|
getX() / getY() | Current position. |
setX(x) / setY(y) | Set a single axis. |
setPosition(x, y) / setPos(x, y) | Set both axes at once. |
move(dx, dy) | Move by an offset on both axes. |
move(speed) | Move forward along the object's current rotation. |
moveX(dx) / moveY(dy) | Move on one axis, blocked automatically by solid colliders. |
changeX(dx) / changeY(dy) | Like moveX/moveY but without re-sending the scene command (cheaper for bulk updates). |
setRotation(deg) / getRotation() | Absolute rotation in degrees. |
rotate(deg) | Rotate relative to current rotation. |
lookAtMouse() | Rotate to face the current mouse position. |
setScale(s) / setScale(sx, sy) / getScale() | Uniform or per-axis scale. |
| Method | Description |
|---|---|
setColor(r, g, b) / setColor(Color c) | Fill color. |
setSize(w, h) | Width and height in pixels. |
setTexture(path) / setImage(path) | Render an image instead of a flat color. |
setLayer(l) / getLayer() | Draw order — higher layers draw on top. |
hide() / show() / visible(bool) / isVisible() | Toggle visibility without destroying the object. |
setTrasparency(alpha0to255) | Opacity. |
setLight(level) | Glow intensity (matches the Inspector's "Light" slider). |
| Method | Description |
|---|---|
setTag(t) / addTag(t) / hasTag(t) / removeTag(t) / getTags() | Free-text tags, usable with Scene.findByTag. |
touch(other) | Returns true if this object's bounds overlap other's right now. |
canColaid(other, enabled) | Enable/disable solid collision resolution between two specific objects. |
onCollisionEnter/Stay/Exit(handler) | Fires when a solid Collider starts/continues/stops touching this object. |
onTriggerEnter/Stay/Exit(handler) | Same, but for non-solid trigger colliders. |
| Method | Description |
|---|---|
clone() / clone(tag) | Spawns a copy at the same position; useful for bullets, particles, enemies. |
kill() / isDead() | Removes the object from the scene. |
moveTo(x, y, ms) | Animates position to a target over time. |
rotateTo(deg, ms) / scaleTo(sx, sy, ms) | Animates rotation/scale over time. |
fadeIn(ms) / fadeOut(ms) | Animates opacity in/out. |
sleep(ms) | Pauses only this object's own scripted timeline. |
Il tipo base per tutto ciò che viene disegnato in una scena 2D: rettangoli, cerchi, triangoli e immagini. Creato con un metodo factory, caricato da una scena salvata, oppure recuperato con Scene.find(...).
VJObject player = VJObject.rect("player", 100, 300, 40, 40, Color.CYAN);
VJObject e = VJObject.circle("enemy", 500, 300, 40, Color.RED);
VJObject loaded = VJObject.load("player", "resources/vj/player.vj");
VJObject byName = Scene.find("player");
| Metodo | Descrizione |
|---|---|
VJObject.rect(name, x, y, w, h, color) | Crea un rettangolo in (x, y) e lo aggiunge alla scena in esecuzione. |
VJObject.circle(name, x, y, diametro, color) | Crea un cerchio. |
VJObject.create(name, shape, x, y, w, h, color) | Factory generica; shape è una delle costanti di Shape. |
VJObject.createImage(name, path, x, y, w, h) | Crea un oggetto basato su immagine da un file sotto resources. |
VJObject.load(name, resourcePath) | Carica trasformazione/colore/texture da un file .vj salvato dall'editor di scena. |
| Metodo | Descrizione |
|---|---|
getX() / getY() | Posizione attuale. |
setX(x) / setY(y) | Imposta un singolo asse. |
setPosition(x, y) / setPos(x, y) | Imposta entrambi gli assi insieme. |
move(dx, dy) | Sposta di un offset su entrambi gli assi. |
move(speed) | Avanza lungo la rotazione attuale dell'oggetto. |
moveX(dx) / moveY(dy) | Sposta su un asse, bloccato automaticamente dai collider solidi. |
changeX(dx) / changeY(dy) | Come moveX/moveY ma senza reinviare il comando di scena (più economico per aggiornamenti massivi). |
setRotation(deg) / getRotation() | Rotazione assoluta in gradi. |
rotate(deg) | Ruota relativamente alla rotazione attuale. |
lookAtMouse() | Ruota per guardare verso la posizione attuale del mouse. |
setScale(s) / setScale(sx, sy) / getScale() | Scala uniforme o per asse. |
| Metodo | Descrizione |
|---|---|
setColor(r, g, b) / setColor(Color c) | Colore di riempimento. |
setSize(w, h) | Larghezza e altezza in pixel. |
setTexture(path) / setImage(path) | Renderizza un'immagine al posto di un colore piatto. |
setLayer(l) / getLayer() | Ordine di disegno — i layer più alti si disegnano sopra. |
hide() / show() / visible(bool) / isVisible() | Attiva/disattiva la visibilità senza distruggere l'oggetto. |
setTrasparency(alpha0a255) | Opacità. |
setLight(livello) | Intensità del glow (corrisponde allo slider "Light" dell'Inspector). |
| Metodo | Descrizione |
|---|---|
setTag(t) / addTag(t) / hasTag(t) / removeTag(t) / getTags() | Tag testuali liberi, usabili con Scene.findByTag. |
touch(other) | Ritorna true se i bounds di questo oggetto si sovrappongono a quelli di other in questo momento. |
canColaid(other, enabled) | Abilita/disabilita la risoluzione della collisione solida tra due oggetti specifici. |
onCollisionEnter/Stay/Exit(handler) | Si attiva quando un Collider solido inizia/continua/smette di toccare questo oggetto. |
onTriggerEnter/Stay/Exit(handler) | Come sopra, ma per collider trigger non solidi. |
| Metodo | Descrizione |
|---|---|
clone() / clone(tag) | Crea una copia nella stessa posizione; utile per proiettili, particelle, nemici. |
kill() / isDead() | Rimuove l'oggetto dalla scena. |
moveTo(x, y, ms) | Anima la posizione verso un target nel tempo. |
rotateTo(deg, ms) / scaleTo(sx, sy, ms) | Anima rotazione/scala nel tempo. |
fadeIn(ms) / fadeOut(ms) | Anima l'opacità in entrata/uscita. |
sleep(ms) | Mette in pausa solo la timeline scriptata di questo oggetto. |
Scene-wide operations: background, search and grouping.
Scene.setBackgroundColor(new Color(20, 22, 30));
VJObject e = Scene.find("enemy");
java.util.List<VJObject> coins = Scene.findAll("coin");
Group enemies = Scene.group("enemies");
| Method | Description |
|---|---|
clear() / clearPrints() | Removes every object from the scene, or just clears console prints. |
setBackgroundColor(Color) | Scene background color. |
setpos(x, y) | Moves the scene's origin/viewport. |
setGrid(visible) | Toggles the editor's reference grid. |
find(name) | Finds a live object by its exact name. |
findByTag(tag) / findAll(tag) | Finds the first, or every, object carrying a tag. |
group(name) | Gets (creating if needed) a named Group of objects. |
Operazioni a livello di scena: sfondo, ricerca e raggruppamento.
Scene.setBackgroundColor(new Color(20, 22, 30));
VJObject e = Scene.find("enemy");
java.util.List<VJObject> coins = Scene.findAll("coin");
Group enemies = Scene.group("enemies");
| Metodo | Descrizione |
|---|---|
clear() / clearPrints() | Rimuove tutti gli oggetti dalla scena, oppure pulisce solo i print in console. |
setBackgroundColor(Color) | Colore di sfondo della scena. |
setpos(x, y) | Sposta l'origine/viewport della scena. |
setGrid(visible) | Attiva/disattiva la griglia di riferimento dell'editor. |
find(name) | Trova un oggetto vivo per nome esatto. |
findByTag(tag) / findAll(tag) | Trova il primo, o tutti, gli oggetti con un dato tag. |
group(name) | Ottiene (creandolo se serve) un Group di oggetti con quel nome. |
Camera.follow(player);
Camera.zoom(1.4);
@onUpdate
void loop() {
Camera._tickFollow();
}
| Method | Description |
|---|---|
move(dx, dy) | Pans the camera by an offset. |
setPosition(x, y) / getX() / getY() | Absolute camera position. |
follow(target) | Camera tracks a VJObject's position every frame. |
zoom(factor) | Sets zoom level. |
rotate(deg) | Rotates the camera. |
Camera.follow(player);
Camera.zoom(1.4);
@onUpdate
void loop() {
Camera._tickFollow();
}
| Metodo | Descrizione |
|---|---|
move(dx, dy) | Sposta la camera di un offset. |
setPosition(x, y) / getX() / getY() | Posizione assoluta della camera. |
follow(target) | La camera segue la posizione di un VJObject ogni frame. |
zoom(factor) | Imposta il livello di zoom. |
rotate(deg) | Ruota la camera. |
@onUpdate
void loop() {
if (Mouse.left()) System.print(Mouse.getX() + "," + Mouse.getY());
}
| Method | Description |
|---|---|
getX() / getY() | Cursor position in scene coordinates. |
left() / right() / middle() | Whether that mouse button is currently held. |
@onUpdate
void loop() {
if (Mouse.left()) System.print(Mouse.getX() + "," + Mouse.getY());
}
| Metodo | Descrizione |
|---|---|
getX() / getY() | Posizione del cursore in coordinate di scena. |
left() / right() / middle() | Se quel pulsante del mouse è attualmente premuto. |
KEY_*Any KEY_NAME used as a boolean condition checks the live keyboard state — no method call needed.
if (KEY_LEFT) player.moveX(-4);
if (KEY_RIGHT) player.moveX(4);
if (KEY_UP) player.moveY(-4);
if (KEY_DOWN) player.moveY(4);
if (KEY_SPACE) player.rotate(90);
if (KEY_A) System.print("A is down");
For the exact key that triggered an event, use @onKeyPress, which passes the key name as a String argument (see Events).
KEY_*Qualsiasi KEY_NOME usato come condizione booleana verifica lo stato attuale della tastiera — nessuna chiamata a metodo necessaria.
if (KEY_LEFT) player.moveX(-4);
if (KEY_RIGHT) player.moveX(4);
if (KEY_UP) player.moveY(-4);
if (KEY_DOWN) player.moveY(4);
if (KEY_SPACE) player.rotate(90);
if (KEY_A) System.print("A is down");
Per sapere esattamente quale tasto ha attivato un evento, usa @onKeyPress, che passa il nome del tasto come argomento String (vedi Eventi).
Every VJObject carries a rigidbody and a collider. Setting a velocity or force "activates" the body — until then, an object is just visually positioned, not simulated.
Physics.gravity(0, 0.8);
VJObject crate = VJObject.rect("crate", 0, -100, 40, 40, Color.ORANGE);
crate.rigidbody.setMass(2);
crate.rigidbody.addForce(0, 0); // dynamic bodies fall under gravity automatically
VJObject wall = VJObject.rect("wall", 200, 0, 20, 300, Color.GRAY);
wall.rigidbody.setStatic();
wall.collider.setLayer(Layer.WORLD);
crate.collider.setMask(Layer.WORLD); // crate reacts to WORLD-layer colliders
crate.onCollisionEnter(other -> System.print("Landed on " + other));
| Method | Description |
|---|---|
Physics.gravity(x, y) | Sets global gravity applied to every dynamic rigidbody. |
Physics.gravity() | Reads the current gravity vector. |
obj.rigidbody)| Method | Description |
|---|---|
setVelocity(x, y) / getVelocityX() / getVelocityY() | Direct velocity control. |
addForce(x, y) | Accumulates force applied over the next step (mass-dependent). |
addImpulse(x, y) | Instant velocity change, ignoring mass scaling of forces. |
setMass(m) / getMass() | Body mass, affects force response. |
setGravityScale(g) | Multiplier on global gravity for this body (0 = unaffected). |
setDrag(d) / setAngularDrag(d) | Velocity damping per step (0–1). |
setStatic() / setKinematic() / setDynamic() | Body type: immovable, moved by script only, or fully simulated. |
setRotationLocked(bool) | Prevents physics from rotating the body. |
obj.collider) & Layer| Method | Description |
|---|---|
setEnabled(bool) / isEnabled() | Turns collision detection on/off for this object. |
setTrigger(bool) / isTrigger() | Non-solid colliders report overlap via onTrigger* but don't block movement. |
setLayer(l) / getLayer() | Which Layer this collider belongs to. |
setMask(m) / getMask() | Which layers this collider should react to. |
Layer.DEFAULT / PLAYER / ENEMY / WORLD / PROJECTILE / PICKUP / UI / ALL / NONE | Predefined layer bit-flags; combine with |, or use Layer.bit(n) for a custom one. |
Ogni VJObject ha un rigidbody e un collider. Impostare una velocità o una forza "attiva" il corpo — fino a quel momento, un oggetto è solo posizionato visivamente, non simulato.
Physics.gravity(0, 0.8);
VJObject crate = VJObject.rect("crate", 0, -100, 40, 40, Color.ORANGE);
crate.rigidbody.setMass(2);
crate.rigidbody.addForce(0, 0); // i corpi dinamici cadono automaticamente per gravità
VJObject wall = VJObject.rect("wall", 200, 0, 20, 300, Color.GRAY);
wall.rigidbody.setStatic();
wall.collider.setLayer(Layer.WORLD);
crate.collider.setMask(Layer.WORLD); // crate reagisce ai collider del layer WORLD
crate.onCollisionEnter(other -> System.print("Atterrato su " + other));
| Metodo | Descrizione |
|---|---|
Physics.gravity(x, y) | Imposta la gravità globale applicata a ogni rigidbody dinamico. |
Physics.gravity() | Legge il vettore di gravità attuale. |
obj.rigidbody)| Metodo | Descrizione |
|---|---|
setVelocity(x, y) / getVelocityX() / getVelocityY() | Controllo diretto della velocità. |
addForce(x, y) | Accumula una forza applicata nel prossimo step (dipendente dalla massa). |
addImpulse(x, y) | Cambio istantaneo di velocità, ignorando lo scaling della massa sulle forze. |
setMass(m) / getMass() | Massa del corpo, influenza la risposta alle forze. |
setGravityScale(g) | Moltiplicatore della gravità globale per questo corpo (0 = non influenzato). |
setDrag(d) / setAngularDrag(d) | Smorzamento della velocità per step (0–1). |
setStatic() / setKinematic() / setDynamic() | Tipo di corpo: immobile, mosso solo da script, o completamente simulato. |
setRotationLocked(bool) | Impedisce alla fisica di ruotare il corpo. |
obj.collider) e Layer| Metodo | Descrizione |
|---|---|
setEnabled(bool) / isEnabled() | Attiva/disattiva il rilevamento delle collisioni per questo oggetto. |
setTrigger(bool) / isTrigger() | I collider non solidi segnalano la sovrapposizione tramite onTrigger* ma non bloccano il movimento. |
setLayer(l) / getLayer() | A quale Layer appartiene questo collider. |
setMask(m) / getMask() | A quali layer questo collider deve reagire. |
Layer.DEFAULT / PLAYER / ENEMY / WORLD / PROJECTILE / PICKUP / UI / ALL / NONE | Bit-flag di layer predefiniti; combinali con |, oppure usa Layer.bit(n) per uno personalizzato. |
VJObject o = VJObject.rect("box", 0, 0, 40, 40, Color.CYAN);
o.setColor(new Color(255, 128, 0));
VJObject img = VJObject.create("badge", Shape.IMAGE, 0, 0, 32, 32, Color.WHITE);
| Item | Description |
|---|---|
new Color(r, g, b) | 0–255 RGB components. |
Color.RED / GREEN / BLUE / WHITE / BLACK / … | Named preset colors. |
Shape.RECT / CIRCLE / TRIANGLE / RHOMBUS / IMAGE | Shape constants used with VJObject.create(...). |
VJObject o = VJObject.rect("box", 0, 0, 40, 40, Color.CYAN);
o.setColor(new Color(255, 128, 0));
VJObject img = VJObject.create("badge", Shape.IMAGE, 0, 0, 32, 32, Color.WHITE);
| Elemento | Descrizione |
|---|---|
new Color(r, g, b) | Componenti RGB 0–255. |
Color.RED / GREEN / BLUE / WHITE / BLACK / … | Colori predefiniti con nome. |
Shape.RECT / CIRCLE / TRIANGLE / RHOMBUS / IMAGE | Costanti di forma usate con VJObject.create(...). |
Screen-space widgets for menus and HUDs, positioned independently of the game camera.
UiText score = new UiText("Score: 0", 20, 20);
UiButton restart = new UiButton("Restart", 20, 60, 120, 36);
restart.onClick(() -> Scene.clear());
UiTextField name = new UiTextField(20, 110, 160, 28);
UiPanel hud = new UiPanel(0, 0, 200, 140);
| Widget | Typical use |
|---|---|
UiText | Static or updatable label text (score, timers, messages). |
UiButton | Clickable button with an onClick(...) handler. |
UiTextField | Single-line text input, e.g. player name entry. |
UiPanel | A background container to group other widgets visually. |
All four share position/size setters and can be shown or hidden like a VJObject.
Widget in coordinate schermo per menu e HUD, posizionati indipendentemente dalla camera di gioco.
UiText score = new UiText("Score: 0", 20, 20);
UiButton restart = new UiButton("Restart", 20, 60, 120, 36);
restart.onClick(() -> Scene.clear());
UiTextField name = new UiTextField(20, 110, 160, 28);
UiPanel hud = new UiPanel(0, 0, 200, 140);
| Widget | Uso tipico |
|---|---|
UiText | Testo statico o aggiornabile (punteggio, timer, messaggi). |
UiButton | Pulsante cliccabile con handler onClick(...). |
UiTextField | Campo di testo su una riga, es. inserimento nome giocatore. |
UiPanel | Un contenitore di sfondo per raggruppare visivamente altri widget. |
Tutti e quattro condividono setter di posizione/dimensione e possono essere mostrati o nascosti come un VJObject.
Reading, writing and browsing files from JVL code — for save files, settings, and asset management.
// Plain text
FileSystem.write("resources/notes.txt", "Hello!");
String content = FileSystem.read("resources/notes.txt");
FileSystem.append("resources/log.txt", "line\n");
boolean ok = FileSystem.exists("resources/notes.txt");
FileSystem.createFolder("resources/saves");
String[] files = FileSystem.list("resources/saves");
// Key/value config, typed reads
Config.write("resources/save.cfg", "level", 3);
int level = Config.readInt("resources/save.cfg", "level", 1);
// JSON
Json.save("resources/state.json", myMap);
Object data = Json.load("resources/state.json");
// Pick a file / folder with a native dialog
String picked = FileDialog.openFile("Images", "*.png");
String folder = FileDialog.selectFolder();
// Zip an asset folder
Zip.compress("resources/level1", "resources/level1.zip");
Zip.extract("resources/level1.zip", "resources/level1");
// Clipboard
Clipboard.setText("copied!");
String pasted = Clipboard.getText();
| Class | Highlights |
|---|---|
FileSystem | create, write, append, read, readLines, writeLines, exists, delete, copy, move, rename, size, lastModified, createFolder, deleteFolder, list, listFolders, home/desktop/documents/downloads/temp/appData, info(path) |
Config | Simple key/value files: write(path,key,value) (String/int/double/boolean overloads), readString/readInt/readDouble/readBool(path,key,default), has, remove, keys. |
Json | save(path,obj[,pretty]), load(path), stringify(obj[,pretty]), parse(json). |
FileDialog | openFile(), openFiles(), saveFile(), selectFolder() — each with optional filter name/pattern and start folder. |
Zip | compress(sourceFolderOrFile, outputZip), extract(zipFile, destinationFolder). |
Clipboard | getText(), setText(text). |
Leggere, scrivere e sfogliare file da codice JVL — per salvataggi, impostazioni e gestione degli asset.
// Testo semplice
FileSystem.write("resources/notes.txt", "Hello!");
String content = FileSystem.read("resources/notes.txt");
FileSystem.append("resources/log.txt", "line\n");
boolean ok = FileSystem.exists("resources/notes.txt");
FileSystem.createFolder("resources/saves");
String[] files = FileSystem.list("resources/saves");
// Config chiave/valore, letture tipizzate
Config.write("resources/save.cfg", "level", 3);
int level = Config.readInt("resources/save.cfg", "level", 1);
// JSON
Json.save("resources/state.json", myMap);
Object data = Json.load("resources/state.json");
// Scegli un file / una cartella con una finestra di dialogo nativa
String picked = FileDialog.openFile("Images", "*.png");
String folder = FileDialog.selectFolder();
// Comprimi una cartella di asset
Zip.compress("resources/level1", "resources/level1.zip");
Zip.extract("resources/level1.zip", "resources/level1");
// Appunti
Clipboard.setText("copied!");
String pasted = Clipboard.getText();
| Classe | Metodi principali |
|---|---|
FileSystem | create, write, append, read, readLines, writeLines, exists, delete, copy, move, rename, size, lastModified, createFolder, deleteFolder, list, listFolders, home/desktop/documents/downloads/temp/appData, info(path) |
Config | File chiave/valore semplici: write(path,key,value) (overload String/int/double/boolean), readString/readInt/readDouble/readBool(path,key,default), has, remove, keys. |
Json | save(path,obj[,pretty]), load(path), stringify(obj[,pretty]), parse(json). |
FileDialog | openFile(), openFiles(), saveFile(), selectFolder() — ciascuno con filtro nome/pattern e cartella iniziale opzionali. |
Zip | compress(sourceFolderOrFile, outputZip), extract(zipFile, destinationFolder). |
Clipboard | getText(), setText(text). |
Run shell commands or external programs, wait on them or read their output, and open files, folders and URLs — this is Visual Java's terminal-command layer.
// Run a shell command and block until it finishes, capturing output
String out = CMD.execute("dir"); // Windows; use "ls" style commands on other OSes
System.print(out);
// Same thing, explicitly
String out2 = VJSystem.exec("git status");
// Launch a long-running external program without blocking
VJProcess proc = VJSystem.run("java", "-version");
proc.waitFor(2000); // wait up to 2s
System.print(proc.getOutput());
System.print(proc.getError());
if (proc.isAlive()) proc.kill();
// Open things with the OS
VJSystem.open("resources/readme.txt");
VJSystem.openFolder("resources");
VJSystem.showInExplorer("resources/readme.txt");
Browser.open("https://github.com/srokopollo-design/visual-java-engen");
Browser.mail("team@example.com");
// System info
System.print(VJSystem.getOS() + " / " + VJSystem.getArchitecture());
System.print("CPUs: " + VJSystem.getCPUCount());
| Class | Highlights |
|---|---|
VJSystem | run(cmd...) (async, returns VJProcess), exec(command) (blocking, returns combined output), open/openFolder/showInExplorer/openURL, exit(), restartApplication(), getOS, getUserName, getComputerName, getArchitecture, getJavaVersion, getCPUCount, getFreeMemory, getTotalMemory, getEnv(name), path shortcuts getDesktop/getDocuments/getDownloads/getAppData/getTemp. |
CMD | execute(command) — a one-line shortcut for VJSystem.exec(...). |
VJProcess | Returned by VJSystem.run(...): isAlive(), getPID(), waitFor(), waitFor(timeoutMs), kill(), killForcibly(), getExitCode(), getOutput(), getError(). |
Browser | open(url), mail(address). |
Use CMD.execute/VJSystem.exec for short commands you want the result of immediately; use VJSystem.run(...) for anything long-running so your game loop keeps ticking while it works in the background.
Esegui comandi shell o programmi esterni, aspettali o leggine l'output, e apri file, cartelle e URL — questo è il livello di comandi da terminale di Visual Java.
// Esegue un comando shell e blocca finché non termina, catturando l'output
String out = CMD.execute("dir"); // Windows; usa comandi tipo "ls" su altri OS
System.print(out);
// Stessa cosa, in modo esplicito
String out2 = VJSystem.exec("git status");
// Avvia un programma esterno di lunga durata senza bloccare
VJProcess proc = VJSystem.run("java", "-version");
proc.waitFor(2000); // aspetta fino a 2s
System.print(proc.getOutput());
System.print(proc.getError());
if (proc.isAlive()) proc.kill();
// Apri elementi con il sistema operativo
VJSystem.open("resources/readme.txt");
VJSystem.openFolder("resources");
VJSystem.showInExplorer("resources/readme.txt");
Browser.open("https://github.com/srokopollo-design/visual-java-engen");
Browser.mail("team@example.com");
// Informazioni di sistema
System.print(VJSystem.getOS() + " / " + VJSystem.getArchitecture());
System.print("CPU: " + VJSystem.getCPUCount());
| Classe | Metodi principali |
|---|---|
VJSystem | run(cmd...) (asincrono, ritorna VJProcess), exec(command) (bloccante, ritorna l'output combinato), open/openFolder/showInExplorer/openURL, exit(), restartApplication(), getOS, getUserName, getComputerName, getArchitecture, getJavaVersion, getCPUCount, getFreeMemory, getTotalMemory, getEnv(name), scorciatoie percorso getDesktop/getDocuments/getDownloads/getAppData/getTemp. |
CMD | execute(command) — scorciatoia in una riga per VJSystem.exec(...). |
VJProcess | Restituito da VJSystem.run(...): isAlive(), getPID(), waitFor(), waitFor(timeoutMs), kill(), killForcibly(), getExitCode(), getOutput(), getError(). |
Browser | open(url), mail(address). |
Usa CMD.execute/VJSystem.exec per comandi brevi di cui vuoi subito il risultato; usa VJSystem.run(...) per qualsiasi cosa di lunga durata, così il tuo game loop continua a girare mentre lavora in background.
Controls the main runtime window created automatically at program start.
Window.main().setTitle("My Game");
Window.main().setSize(1024, 640);
Window.main().setFullscreen(true);
Only the main window is controllable in 1.7 — creating additional independent windows (Window.create(...) / dialogs) isn't implemented yet.
Controlla la finestra principale del runtime, creata automaticamente all'avvio del programma.
Window.main().setTitle("My Game");
Window.main().setSize(1024, 640);
Window.main().setFullscreen(true);
Nella 1.7 è controllabile solo la finestra principale — la creazione di finestre indipendenti aggiuntive (Window.create(...) / dialog) non è ancora implementata.