Class: Sprite

DKTools.Sprite

new DKTools.Sprite ()

Extends

  • Sprite

Mixes In

Classes

Button

Members

_align String privatereadonly

_fillColor String | null privatereadonly

_fixedBitmap Boolean privatereadonly

_font Object privatereadonly

_graphicFolder String privatereadonly

_graphicLoadListener function privatereadonly

_graphicName String privatereadonly

_paintOpacity Number privatereadonly

_textColor String privatereadonly

align String readonly

Text align

contents Bitmap | null

Bitmap of the sprite To support functions from DKTools.Base
Since:
  • 7.0.0

fillColor String | null readonly

Fill color

font Object readonly

Text font

graphicFolder String readonly

Graphic folder

graphicName String readonly

Graphic name

paintOpacity Number readonly

Paint opacity

textColor String readonly

Text color

windowskin Bitmap | null readonly

Window skin

Methods

_loadGraphic () private

Loads the graphic (using graphic folder and graphic name)

canRedrawAll ()Boolean

Returns true if the sprite can be updated and redrawn
Since:
  • 1.1.0
Returns:
Type Description
Boolean Sprite can be updated and redrawn

changeFont (font)

Changes the font of the bitmap
Name Type Description
font Object Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

changePaintOpacity (paintOpacity)

Changes the paint opacity of the bitmap
Name Type Description
paintOpacity Number Paint opacity

changeTextColor (textColor)

Changes the text color of the bitmap
Name Type Description
textColor String Text color

createAll ()

Creates all objects
Version:
  • 10.0.0

createBitmap ()

Loads an image by graphic name (if exists) or create the bitmap (if the fixed bitmap does not exist)
Version:
  • 1.1.0

drawAll ()

Draws all

drawText (text, options)Boolean

Draws a text Returns true if successfully completed
Name Type Default Description
text String Text
options Object {} optional Options for drawing
Name Type Description
font Object optional Use custom font
textColor String optional Use custom text color
paintOpacity Number optional Use custom paint opacity
align String optional Align
resetFont Boolean optional Use standard font after drawing the text
resetTextColor String optional Use standard text color after drawing the text
resetPaintOpacity String optional Use standard paint opacity after drawing the text
x Number optional The X coordinate
y Number | String optional The Y coordinate or line number (String)
width Number optional Width of the rectangle
height Number | String optional Height of the rectangle or number of lines (String)
pos Point | Object optional Position of the text (ignores other parameters of position: x, y)
rect Rectangle | Object optional Rectangle for drawing (ignores other parameters of position: x, y, width, height, pos)
pos.x Number optional The X coordinate
pos.y Number | String optional The Y coordinate or line number (String)
rect.x Number optional The X coordinate
rect.y Number | String optional The Y coordinate or line number (String)
rect.width Number | String optional Width of the rectangle
rect.height Number | String optional Height of the rectangle or number of lines (String)
Version:
  • 6.3.0
Returns:
Type Description
Boolean Successfully completed
Example
var sprite = new DKTools.Sprite(0, 0, 100, 36);

sprite.start();

sprite.drawText('Text', { y: '1' });

getLocalPoint (object, y)PIXI.Point

Returns the local point (coordinates inside the sprite)
Name Type Description
object Number | PIXI.Point | PIXI.ObservablePoint | Point | Object optional The X coordinate or Point or object with parameters
y Number optional The Y coordinate (if object is Number)
object.x Number optional The X coordinate
object.y Number optional The Y coordinate
Since:
  • 8.0.0
Returns:
Type Description
PIXI.Point Local point (coordinates inside the sprite)

hasFillColor ()Boolean

Returns true if the sprite has the fill color
Returns:
Type Description
Boolean Sprite has the fill color

hasFixedBitmap ()Boolean

Returns true if the sprite has fixed bitmap (setted using setupBitmap or setBitmap)
Since:
  • 1.1.0
Returns:
Type Description
Boolean Sprite has fixed bitmap (setted using setupBitmap or setBitmap)

hasGraphicFolder ()Boolean

Returns true if the sprite has the graphic folder
Returns:
Type Description
Boolean Sprite has the graphic folder

hasGraphicName ()Boolean

Returns true if the sprite has the graphic name
Returns:
Type Description
Boolean Sprite has the graphic name

initialize (object, y, width, height, object)

Initializes a class object
Name Type Description
object Number | DKTools.Sprite | Bitmap | Rectangle | Object optional The X coordinate or Sprite or Bitmap or Rectangle or object with properties
y Number optional The Y coordinate (if object is Number)
width Number optional Width of the bitmap (if object is Number)
height Number optional Height of the bitmap (if object is Number)
object.x Number optional The X coordinate
object.y Number optional The Y coordinate
object.width Number optional Width of the bitmap
object.height Number optional Height of the bitmap
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap
Version:
  • 10.0.0

isResizable ()Boolean

Returns true if you can change the size of the sprite
Version:
  • 1.1.0
Returns:
Type Description
Boolean You can change the size of the sprite

lineHeight ()Number

Returns the height of the line
Returns:
Type Description
Number Height of the line

loadBitmap (object, filename, listener, hue, smooth)Boolean

Loads a bitmap Returns true if the bitmap has been changed
Name Type Description
object String | Object Path to file or object with parameters
filename String Name of file (if object is String)
listener function optional Function of processing after loading a bitmap (if object is String)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
object.folder String Path to file
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

loadSystem (object, listener, hue, smooth)Boolean

Loads a bitmap from img/system/ Returns true if the bitmap has been changed
Name Type Description
object String | Object Name of file or object with parameters
listener function optional Function of processing after loading a bitmap (if object is String)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
Returns:
Type Description
Boolean Bitmap has been changed

loadWindowskin (object, listener, hue, smooth)Boolean

Loads a window skin from img/system/ Returns true if the bitmap has been changed
Name Type Description
object String | Object Name of file or object with parameters
listener function optional Function of processing after loading a bitmap (if object is String)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
Returns:
Type Description
Boolean Bitmap has been changed

moveWithAnchor (x, y)

Moves the sprite (taking into account the anchor)
Name Type Description
x Number optional The X coordinate or Point or object with parameters
y Number | String optional The Y coordinate or line number (String) (if object is Number)
Version:
  • 10.0.0
Since:
  • 5.0.0

removeBitmap ()

Removes the bitmap

reserveBitmap (object, filename, listener, hue, smooth, reservationId)Boolean

Loads and reserves a bitmap Returns true if the bitmap has been changed
Name Type Description
object String | Object Path to file or object with parameters
filename String Name of file (if object is String)
listener function optional Function of processing after loading a bitmap (if object is String)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
reservationId Number optional Reservation ID (if object is String)
object.folder String Path to file
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
object.reservationId Number optional Reservation ID
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

reserveSystem (object, listener, hue, smooth, reservationId)Boolean

Loads and reserves a bitmap from img/system/ Returns true if the bitmap has been changed
Name Type Description
object String | Object Name of file or object with parameters
listener function optional Function of processing after loading a bitmap (if object is String)
hue Number optional Hue of bitmap (if object is String)
smooth Boolean optional Smooth of bitmap (if object is String)
reservationId Number optional Reservation ID (if object is String)
object.filename String Name of file
object.listener function optional Function of processing after loading a bitmap
object.hue Number optional Hue of bitmap
object.smooth Boolean optional Smooth of bitmap
object.reservationId Number optional Reservation ID
Version:
  • 3.0.0
Returns:
Type Description
Boolean Bitmap has been changed

resetAll ()

Resets all

resetFont ()

Resets the font of the bitmap

resetPaintOpacity ()

Resets the paint opacity of the bitmap

resetTextColor ()

Resets the text color of the bitmap

resize (width, height, blockStart)Boolean

Changes the width and height of the sprite Returns true if the change occurred
Name Type Default Description
width Number Width of the sprite
height Number | String Height of the sprite or number of lines (String)
blockStart Boolean false optional Blocking the call of the "start" function
Version:
  • 10.0.0
Returns:
Type Description
Boolean Change occurred

setAlign (align, blockRefreshAll)Boolean

Changes the align Returns true if the change occurred
Name Type Default Description
align String optional Text align
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setBitmap (object)Boolean

Changes the bitmap Returns true if the change occurred
Name Type Description
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap
Returns:
Type Description
Boolean Change occurred

setFillColor (color, blockRefreshAll)Boolean

Changes the fill color Returns true if the change occurred
Name Type Default Description
color String optional Fill color
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setFont (font, blockStart)Boolean

Changes the font of the bitmap Returns true if the change occurred
Name Type Default Description
font Object optional Text font
blockStart Boolean false optional Blocking the call of the "start" function
font.fontFace String optional Font face
font.fontSize Number optional Font size
font.fontItalic Boolean optional Font italic
Returns:
Type Description
Boolean Change occurred

setGraphicFolder (folder, blockStart)Boolean

Changes the graphic folder Returns true if the change occurred
Name Type Default Description
folder String optional Graphic folder
blockStart Boolean false optional Blocking the call of the "start" function
Returns:
Type Description
Boolean Change occurred

setGraphicName (graphicName, blockStart)Boolean

Changes the graphic name Returns true if the change occurred
Name Type Default Description
graphicName String optional Graphic name
blockStart Boolean false optional Blocking the call of the "start" function
Returns:
Type Description
Boolean Change occurred

setPaintOpacity (opacity, blockRefreshAll)Boolean

Changes the paint opacity Returns true if the change occurred
Name Type Default Description
opacity Number optional Paint opacity
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setTextColor (color, blockRefreshAll)Boolean

Changes the text color Returns true if the change occurred
Name Type Default Description
color String optional Text color
blockRefreshAll Boolean false optional Blocking the call of the "refreshAll" function
Returns:
Type Description
Boolean Change occurred

setupAlign (align)

Sets the align
Name Type Default Description
align String this.standardAlign() optional Text align

setupAll (object)

Sets all parameters
Name Type Default Description
object Object {} optional Parameters
Name Type Description
bitmap Bitmap | Object optional Bitmap or object with parameters
frame Rectangle optional Frame of the sprite
anchor Point optional Anchor of the sprite
align String optional Text align
font Object optional Text font
textColor String optional Text color
paintOpacity Number optional Paint opacity
fillColor String optional Fill color
graphicFolder String optional Graphic folder
graphicName String optional Graphic name
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap
font.fontFace String optional Font face
font.fontSize Number optional Font size
font.fontItalic Boolean optional Font italic
Version:
  • 10.0.0

setupAnchor (object, y)

Sets the anchor of the sprite
Name Type Description
object Number | Point optional The X coordinate or Point
y Number optional The Y coordinate (if object is Number)
Version:
  • 10.0.0

setupBitmap (object)

Sets the bitmap
Name Type Description
object Bitmap | Object optional Bitmap or object with parameters
Name Type Description
folder String Path to file
filename String Name of file
listener function optional Function of processing after loading a bitmap
hue Number optional Hue of bitmap
smooth Boolean optional Smooth of bitmap
Version:
  • 10.0.0

setupFillColor (color)

Sets the fill color
Name Type Description
color String optional Fill color

setupFont (font)

Sets the font of the bitmap
Name Type Description
font Object optional Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

setupFrame (object, y, width, height)

Sets the frame of the sprite
Name Type Description
object Number | Rectangle optional The X coordinate or Rectangle
y Number optional The Y coordinate (if object is Number)
width Number optional Width of the frame (if object is Number)
height Number optional Height of the frame (if object is Number)
Version:
  • 10.0.0

setupGraphicFolder (folder)

Sets the graphic folder
Name Type Description
folder String optional Path to folder

setupGraphicLoadListener (listener)

Sets the listener on load of graphic
Name Type Description
listener function Listener

setupGraphicName (graphicName)

Sets the graphic name
Name Type Description
graphicName String optional Graphic name

setupPaintOpacity (opacity)

Sets the paint opacity
Name Type Description
opacity Number optional Paint opacity

setupSize (width, height)

Sets the size of the bitmap
Name Type Description
width Number optional Width of the bitmap
height Number | String optional Height of the bitmap
Version:
  • 10.0.0

setupTextColor (color)

Sets the color of the text
Name Type Description
color String optional Text color

standardAlign ()String

Returns the standard text align
Returns:
Type Description
String Standard text align

standardAnchor ()Point

Returns the standard anchor
Returns:
Type Description
Point Standard anchor

standardFillColor ()String | null

Returns the standard fill color
Returns:
Type Description
String | null Standard fill color

standardFont ()Object

Returns the standard font
Version:
  • 10.0.5
Returns:
Type Description
Object Standard font

standardFontBold ()Boolean

Returns the standard font bold
Since:
  • 10.0.5
Returns:
Type Description
Boolean Standard font bold

standardFontFace ()String

Returns the standard font face
Version:
  • 8.2.0
Returns:
Type Description
String Standard font face

standardFontItalic ()Boolean

Returns the standard font italic
Returns:
Type Description
Boolean Standard font italic

standardFontSize ()Number

Returns the standard font size
Version:
  • 8.2.0
Returns:
Type Description
Number Standard font size

standardFrame ()Rectangle

Returns the standard frame
Version:
  • 8.0.0
Returns:
Type Description
Rectangle Standard frame

standardGraphicFolder ()String

Returns the standard graphic folder
Returns:
Type Description
String Standard graphic folder

standardGraphicName ()String

Returns the standard graphic name
Returns:
Type Description
String standard graphic name

standardPaintOpacity ()Number

Returns the standard paint opacity
Returns:
Type Description
Number Standard paint opacity

standardTextColor ()String

Returns the standard text color
Returns:
Type Description
String Standard text color

update ()

Updates the sprite

updateAll ()

Updates all

updateBitmap ()

Updates the bitmap

updateFill ()

Updates the fill of the sprite

updateFont (font)

Updates the font of the bitmap
Name Type Default Description
font Object {} optional Text font
Name Type Description
fontFace String optional Font face
fontSize Number optional Font size
fontItalic Boolean optional Font italic

updatePaintOpacity (paintOpacity)

Updates the paint opacity
Name Type Description
paintOpacity Number optional Paint opacity

updateTextColor (textColor)

Updates the text color
Name Type Description
textColor String optional Text color