...

Source file src/gitlab.com/tslocum/venture/pkg/world/scene.go

Documentation: gitlab.com/tslocum/venture/pkg/world

     1  package world
     2  
     3  import "github.com/hajimehoshi/ebiten"
     4  
     5  // Scene is a node which organizes nodes.
     6  type Scene struct {
     7  	*Logic
     8  }
     9  
    10  // NewScene returns a new Scene.
    11  func NewScene(updateFunc func(screen *ebiten.Image) error) *Scene {
    12  	return &Scene{NewLogic(updateFunc)}
    13  }
    14  
    15  // SetNode sets the nodes of a scene.
    16  func (n *Scene) SetNode(node Node) {
    17  	n.nodes = []Node{node}
    18  }
    19  
    20  // SetNodes sets the nodes of a scene.
    21  func (n *Scene) SetNodes(nodes []Node) {
    22  	n.nodes = nodes
    23  }
    24  
    25  // RemoveNode removes the provided node from a scene.
    26  func (n *Scene) RemoveNode(node Node) {
    27  	for i, subNode := range n.nodes {
    28  		if subNode == node {
    29  			n.nodes = append(n.nodes[:i], n.nodes[i+1:]...)
    30  			return
    31  		}
    32  	}
    33  }
    34  
    35  // Clear removes all nodes from a scene.
    36  func (n *Scene) Clear() {
    37  	n.nodes = nil
    38  }
    39  

View as plain text