Skip to content

Guide Beginner Overview

Carlonn Rivers edited this page Jul 21, 2021 · 7 revisions

Beginner Overview

Required Knowledge

Things you should know before starting:

HTML, JavaScript

Expected Learning

The beginner guide will give you an introduction to the following:

Scenes, Prefab, Sprites

End Result

Here's an idea of what we will be creating in this section:

first_application

Code Review

You can refer to this code while following the guide:

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>First FlevaR Application</title>
    
    <!-- include our engine -->
    <script src="https://unpkg.com/[email protected]/dist/flevar.js"></script>

    <!-- include main application script -->
    <script defer src="main.js"></script>
</head>
<body>
    <!-- container for our application -->
    <div id="flevaRContainer"></div>
</body>
</html>

main.js:

const flevaRContainerElement = document.getElementById("flevaRContainer");
FlevaR(flevaRContainerElement, function onload(flevar) {
    const _root = flevar._root;

    flevar.createSprite("first_sprite");

    flevar.createPrefab("first_prefab", function onload(prefab) {
        prefab._x = 50;
        prefab._y = 100;
        prefab.setAppearance(function (prefab) {
            prefab.useSprite("first_sprite");
        });
    });

    flevar.createScene("first_scene", function onload(scene) {
        scene.addPrefab("first_prefab");
    });

    flevar.useScene("first_scene");

    _root._color = "green";
});