GameObject TypeIn GameCrom, a GameObject is the base type for every element in a scene: enemies, platforms, triggers, decorations or logic elements.
This type has no built-in behavior, making it the most flexible object in the engine. Its physical, visual and logical properties are fully controlled through scripts or components.
GameObject is one of the possible values for the type field.player, light,
or particleSystem) extends these base properties.
GameObject Properties| Property | Type | Description | Default |
|---|---|---|---|
name | string | Name shown in the hierarchy. | "GameObject" |
type | string | Object type ("gameobject"). | "gameobject" |
x | number | Horizontal position (pixels). | 0 |
y | number | Vertical position. | 0 |
w | number | Width of the object. | 32 |
h | number | Height of the object. | 32 |
scaleX | number | Horizontal scale. | 1 |
scaleY | number | Vertical scale. | 1 |
rotation | number | Rotation in degrees. | 0 |
vx | number | Horizontal velocity (pixels/second).
Commonly used as obj.x += obj.vx * dt. |
0 |
vy | number | Vertical velocity.
Ideal for jumps or gravity: obj.vy += obj.gravity * dt. |
0 |
gravity | number | Gravity intensity applied to the object. If 0, the object will not fall.You can adjust it to change the object's “weight”. |
400 |
static | boolean | If true, the object is static:
it will not move nor be affected by physics or dynamic collisions.
Ideal for walls, floors, or fixed platforms. |
false |
color | string | Rectangle color (if no sprite is assigned). | "#ffffff" |
opacity | number | Transparency (0–1). | 1 |
visible | boolean | Determines if the object is drawn on screen. | true |
active | boolean | If inactive, it will not update. | true |
image | string | Sprite path or name used for rendering. | null |
collision | boolean | Enables physics collisions (AABB or circle). | false |
trigger | boolean | Detects enter/exit events only; no physical blocking. | false |
tag | string | Identification tag (e.g. “Player”, “Enemy”). | "" |
layer | number | Draw order (0–31). | 0 |
components | array | Attached components (animation, audio, particles...) | [] |
script | string|null | Assigned script (e.g. "player_platform.js"). | null |
// Basic physics script
function Update(obj, dt) {
if (!obj.static) {
obj.vy += obj.gravity * dt; // gravity
obj.x += obj.vx * dt;
obj.y += obj.vy * dt;
}
// Floor detection
if (obj.y > 400) {
obj.y = 400;
obj.vy = 0;
}
}
gravity property defines how fast the object accelerates downward per second.static property prevents the engine from applying movement or gravity.
let rock = instantiateObject({
name: "Rock",
type: "gameobject",
color: "#777",
x: 200,
y: 0,
w: 48,
h: 48,
gravity: 800, // falls faster
static: false
});
let ground = instantiateObject({
name: "Ground",
type: "gameobject",
color: "#3c3c3c",
x: 0,
y: 400,
w: 512,
h: 64,
static: true, // immovable
collision: true
});
gravity for any object that should fall.static: true for platforms, walls or fixed decorations.gravity can be modified at runtime to create low-gravity areas or floating effects.vx and vy work independently from gravity, allowing horizontal movement + falling.static: true and collision: true
behaves like a solid block—perfect for building level environments.