Inherits from Node
Location aphid.g2d.Sprite

Overview

The Sprite class displays a rectangular area of a Texture2D on the screen.

Default Anchor of Sprite

Unlike the Node class, the default anchor is (0.5, 0.5), which is the center point of a sprite.

Overview of Constructors

Overview of Tasks

Attributes

  • Type
  • color
  • bool
  • bool
  • Point
  • int
  • Texture2D
  • Rect
  • Writability
  • readwrite
  • readwrite
  • readwrite
  • readonly
  • readwrite
  • readwrite
  • readwrite

Class Attributes

  • Type
  • bool
  • bool
  • Writability
  • readwrite
  • readwrite

Constructors

Sprite(texture, [rect])

Creates a sprite which displays a part of a texture on the screen.

new Sprite(Texture2D texture, [Rect rect])

Parameters

Texture2D texture
Optional Non-null Rect rect

Discussion

The contentSize of the sprite will be set to the value of rect.size.

Sprite()

Creates a sprite without a texture. It can be used as a replacement of ColorNode.

new Sprite()

Attributes

color

Non-null readwrite color color

flipX

readwrite bool flipX

flipY

readwrite bool flipY

offsetPositionInPixels

Non-null readonly Point offsetPositionInPixels

opacity

readwrite int opacity

texture

readwrite Texture2D texture

textureRect

Non-null readwrite Rect textureRect

Class Attributes

Sprite.debugDrawOutline

readwrite bool debugDrawOutline

Discussion

Set to true to draw a white line box around each sprite. It’s useful for debugging. Default is false.

Sprite.debugDrawTextureOutline

readwrite bool debugDrawTextureOutline