Drawable

Abstract drawable class - all drawables extend from this

Properties

  • name (string) — -------------Values That Can Be Changed------------
  • offset (dynamic) — The offset of the image from the owner's position
  • scale (dynamic) — The image scale
  • rotation (dynamic) — Rotation of the image
  • color (integer) — This can be used to tint the image with the provided color if desired. White makes no change to the original image.
  • outlineRGBA (integer) — RGB color for the outline stroke. Leave invalid for no outline at all.
  • outlineWidth (integer) — Thickness of the outline stroke, in pixels. Only used when outlineRGBA is set.
  • alpha (float) — Change the image alpha (transparency).
  • enabled (boolean) — Whether or not the image will be drawn.
  • transformationMatrix (dynamic)
  • motionChecker (MotionChecker)
  • shouldRedraw (boolean)
  • geometryVersion (integer) — Bumped every time this drawable's geometry changes in a way the ' position/rotation/scale dirty-checking can't see - a rectangle being resized, for ' instance. SceneObject compares against it to know it has to recompute projected ' geometry even though nothing moved. Bump it via invalidateGeometry().
  • anchor (dynamic) — Normalized anchor point (0-1 on each axis) this drawable pivots around, where (0,0) is ' the top left corner (today's default behavior for every existing drawable) and (1,1) is ' the bottom right. Change it via setAnchor(), not by assigning directly - the renderer ' needs to know the geometry changed.
  • anchorIsSet (boolean) — Whether setAnchor() has ever been called. Image consults this to decide whether to keep ' honoring whatever pretranslation is already on its region (e.g. from a sprite atlas ' pivot) or to override it - see Image.applyAnchorToRegion().
  • owner (GameEntity) — owner GameEntity
  • width (float)
  • height (float)
  • sceneObjects (dynamic)
  • drawMode (SceneObjectDrawMode)
  • isShaded (boolean)

Constructor

new Drawable( owner: GameEntity, args?: roAssociativeArray, ): Drawable

Parameters

  • owner (GameEntity)
  • args (roAssociativeArray, optional, default: "{}")

Instance Methods

addToScene(rendererScene: Renderer): BGE.SceneObject

Adds the Drawable object to the given render scene.

Parameters

Returns

  • BGE.SceneObject — The SceneObject that represents this Drawable in the scene, if applicable

removeFromScene(rendererScene: Renderer): void

Parameters

Returns

  • void

computeTransformationMatrix(): void

Returns

  • void

invalidateGeometry(): void

Marks this drawable's geometry as changed, so the renderer recomputes its world and canvas geometry on the next frame. Movement is dirty-checked automatically (see MotionChecker), but a change in shape - resizing a rectangle, replacing a polygon's points - isn't visible to that check and has to be declared.

Returns

  • void

getAnchor(): BGE.Math.Vector

Returns

  • BGE.Math.Vector

setAnchor(x: float, y: float): void

Sets the normalized anchor point this drawable pivots around. (0,0) is top left (the default), (0.5, 1) is bottom-center, etc. This isn't movement, so it can't be picked up by the per-frame MotionChecker dirty-check - invalidateGeometry() tells the renderer to recompute this drawable's projected geometry even though nothing moved.

Parameters

  • x (float)
  • y (float)

Returns

  • void

movedLastFrame(includeOwner?: boolean): boolean

Parameters

  • includeOwner (boolean, optional, default: false)

Returns

  • boolean

update(): void

Returns

  • void

onResume(pausedTimeMs: integer): void

Parameters

  • pausedTimeMs (integer)

Returns

  • void

isEnabled(): boolean

Returns

  • boolean

getSize(): SizeWH

Returns

getDrawnSize(): SizeWH

Returns

getWorldPosition(): BGE.Math.Vector

Returns

  • BGE.Math.Vector

getPretranslation(): BGE.Math.Vector

Returns

  • BGE.Math.Vector

getFillColorRGBA(ignoreColor?: boolean): integer

Parameters

  • ignoreColor (boolean, optional, default: false)

Returns

  • integer

getOutlineColorRGBA(ignoreColor?: boolean): integer

Parameters

  • ignoreColor (boolean, optional, default: false)

Returns

  • integer

hasOutline(): boolean

Whether this drawable should be stroked with an outline, which is the case once outlineRGBA has been given a color. Setting outlineRGBA is what turns outline drawing on - there is no separate flag - so this is the check the renderer uses to skip all outline work for the (common) drawables that don't want one.

Returns

  • boolean — true if an outline should be drawn for this drawable

getSceneObjectName(extraBit?: string): string

protected

Parameters

  • extraBit (string, optional, default: "\"\"")

Returns

  • string

addSceneObjectToRenderer( sceneObj: SceneObject, renderScene: Renderer, ): SceneObject

protected

Parameters

Returns

drawRegionToCanvas( region: ifDraw2d, additionalRotation?: BGE.Math.Vector, ignoreColor?: boolean, drawTo?: ifDraw2D, ): void

protected

Parameters

  • region (ifDraw2d)
  • additionalRotation (BGE.Math.Vector, optional, default: "invalid")
  • ignoreColor (boolean, optional, default: false)
  • drawTo (ifDraw2D, optional, default: "invalid")

Returns

  • void

forEachSceneObject( operation: function, context: roAssociativeArray, ): void

Parameters

  • operation (function)
  • context (roAssociativeArray)

Returns

  • void