# nodesnim/nodes2d/sprite

Dark Mode

Search:
Group by:

It provides display sprites.

# Imports

../thirdparty/opengl, ../core/vector2, ../core/rect2, ../core/anchor, ../core/input, ../core/enums, ../core/image, ../core/color, ../nodes/node, node2d

# Types

    SpriteObj = object of Node2DObj
      filter*: ColorRef
      texture*: GlTextureObj

    SpriteRef = ref SpriteObj

# Procs

    proc Sprite(name: string = "Sprite"): SpriteRef {...}{.raises: [], tags: [].}

  Creates a new Sprite.

  Arguments:

  - `name` is a node name.

  Examples:

      var node = Sprite("Sprite")

# Methods

    method draw(self: SpriteRef; w, h: GLfloat) {...}{.raises: [GLerror], tags: [].}

  this method uses in the `window.nim`.

    method duplicate(self: SpriteRef): SpriteRef {...}{.base, raises: [], tags: [].}

  Duplicates Sprite object and create a new Sprite.

    method getGlobalMousePosition(self: SpriteRef): Vector2Ref {...}{.inline, raises: [],
        tags: [].}

  Returns mouse position.

    method loadTexture(self: SpriteRef; file: cstring; mode = GL_RGB) {...}{.base,
        raises: [GLerror], tags: [].}

  Loads a new texture from file.

  Arguments:

  - `file` is a texture path.
  - `mode` is a GLenum. can be GL_RGB or GL_RGBA.

    method setTexture(self: SpriteRef; texture: GlTextureObj) {...}{.base, raises: [], tags: [].}

  Loads a new texture from file.

  Arguments:

  - `texture` is a GlTexture object.