API Docs for: 0.1.1
Show:

flatworld.UI Class

Main class for showing UI on the map, like unit selections, movements and such. Has nothing to do with showing off-map data, like datagrams of the resources player has or other players status etc. Good examples for what this shows are: selected units-list, selection highlight (like a circle on the selected unit), unit movement. How it works is that this is basically the interface that shows what the UI theme class can (or must) implement.

Item Index

Methods

Methods

add

(
  • name
  • urls
  • options
)
Object

Add a sound to be used.

Parameters:

  • name String

    Name / identifier

  • urls String

    An array of urls or one url

  • options Object

    OPTIONAL

    • loop Booleam

      Wether the sound will be looped or not

    • volume Object

      The volume of the sound (0 - 1)

Returns:

Object:

Created instance of sound

extend

(
  • newMethod
)
static

Adds a new method to this class

Parameters:

  • newMethod String

    Name of the new method

fade

(
  • name
  • from
  • to
  • duration
)
Promise

Fade the sound in or out

Parameters:

  • name String

    Name / identifier of the sound

  • from Object

    Volume to fade from

  • to Object

    Volume to fade to

  • duration Object

    Time in milliseconds to fade

Returns:

Promise:

Promise that resolves after fade is complete

play

(
  • name
)

Start the sounds playback

Parameters:

  • name String

    Name of the sound to play

remove

(
  • name
)

Remove the sound from usage and memory

Parameters:

  • name String

    Name / identifier of the sound to be removed

showSelections

(
  • objects
  • getDatas
  • {}
)
Boolean static

Responsible for showing what objects have been selected for inspection or if the player selects only one object, we hightlihgt it. For example if there are several objects in one tile on the map and the player needs to be able to select one specific unit on the stack. This is always defined in the UI theme-module Selecting one unit, highlight it, which means, e.g. bringing the unit on top on the map and showing selection circle around it.

Parameters:

  • objects Array | Object

    Objects that have been selected.

  • getDatas Object

    This is an object made of functions, that get wanted data from the object. For example if you have objects name in object.data.specialData.name, then you have an object getDatas.name(), which retrieves this. This should be standardized maybe in MapDataManipulator, so that we can change the template between different game setups easier. Lets say if one game modification has different attributes than another, then maybe it should still have standard interface.

    • name Object

      Retrieves object name

  • {} Object

    Extra options

    • filters MapDataManipulator

      Filters objects

    • options Object

      Extra options that are passed to the UITheme class

Returns:

showUnitMovement

(
  • options
)
static

Shows arrow or movement or what ever to indicate the selected unit is moving to the given location

Parameters:

  • options Object

    Extra options. Like dropping a shadow etc.

stop

(
  • name
)

stop sound playback

Parameters:

  • name String

    Name of the sound to stop playing