Aego Русский

Tags

Tags names groups this node belongs to; scripts find them with scene.WithTag.

component engine.Tags
On this page

Try it

Find a parent tag

The target has the tag Enemy.Flying. A query for Enemy also finds it, so the marker is green.

Expand Tags in the Inspector and replace Enemy.Flying with Ally. The scene restarts and the actual Enemy query no longer finds the target; the marker turns orange. Reset restores Enemy.Flying.

Starts the scene; open the example parameters to experiment.
Open in AegoDownload example project
Scene2 nodes
Target
Transform
position[0, 0]rotation0scale[1, 1]
Tags
tags[]string["Enemy.Flying"]
Sprite Renderer
spriteTextureasset("ae900000000000000000000000000010")tintColor#0dcc40ffsizeVec2[3, 2]
Camera
Transform
position[0, 0]rotation0scale[1, 1]
Camera 2D
zoomfloat40clearColorColor#111827ffscaleenumfitVirtualvirtualVec2[960, 540]activebooltrue
Scriptmain.aes
package demo

// HasTag queries the scene index, including dot-separated parent tags.
script TagIndicator {
    func Update(dt float) {
        if node.HasTag("Enemy") {
            node.Get<SpriteRenderer>().Tint = Color{0.05, 0.8, 0.25, 1}
        } else {
            node.Get<SpriteRenderer>().Tint = Color{1, 0.5, 0.05, 1}
        }
    }
}

Fields

NameTypeDefaultDescription
Tags[]string[]

Dot-separated names like Enemy.Flying; a node tagged Enemy.Flying is also found by Enemy.

From a script

Tags are read from scripts through aego/scene: find every node with a tag, or check a node you collided with.

package game

import (
    "aego/log"
    "aego/scene"
)

script CountEnemies {
    var found []NodeRef

    func Ready() {
        for i := 0; i < 32; i++ {
            found = append(found, nil)
        }
        n := scene.WithTag("Enemy", found)
        log.Info("enemies in the level: " + string(n))
    }
}