gma.enemy

Provides a base enemy object

Package

gma/entities/enemy

Inheritance chain

gma.shapes.rectangle >> gma.moveable

Descendants

gma.platformEnemy, gma.jumpingEnemy, gma.patrolEnemy

Tags

shape, moveable, enemy

Methods

getMovement (moveAmount) -> Amount to move as [x, y]
Enemy getMovement will first call determineState before doing super.getMovement
The enemy is the same as the character, except it
determines it’s own next state, rather than the player

Overrides gma.moveable.getMovement

Parameters

moveAmount

Number

The amount the character should move

determineState (moveAmount, manager)
Determine the state of the enemy for the next movement
- Calls behaviour__jumping if it has jumping tag
- Calls behaviour__patrolling if it has patrolling tag
- Calls behaviour__platformer if it has platformer tag

Parameters

moveAmount

Number

amount to move; based on delta from twitch

manager

gma.manager

collided (where, focus, focusSide, focusVector)
Enemy looks for rebound and weakhead tags as well as what super.collided looks for
It will also look for deathtouch, if enemy is still alive after all other checks

Overrides gma.shapes.rectangle.collided

Parameters

where

gma.constant

Side of this object that was collided with

focus

object

Thing we collided with

focusSide

gma.constant

Side of the focus object that was collided with

focusVector

[x,y]

Amount focus is trying to move

behaviour__jumping (moveAmount, manager)

Makes enemy jump when touching ground

Parameters

moveAmount

Number

amount to move; based on delta from twitch

manager

gma.manager

behaviour__platformer (moveAmount, manager)

Makes enemy turn around when reaching the edge of the platform it is currently on

Parameters

moveAmount

Number

amount to move; based on delta from twitch

manager

gma.manager

behaviour__patrolling (moveAmount, manager)
Makes enemy patrol a range
Requires self.limitLeft and/or self.limitRight properties

Parameters

moveAmount

Number

amount to move; based on delta from twitch

manager

gma.manager

collided__rebound (where, focus, focusSide, focusVector)

Makes enemy turn around if it hits something

Parameters

where

gma.constant

Side of this object that was collided with

focus

object

Thing we collided with

focusSide

gma.constant

Side of the focus object that was collided with

focusVector

[x,y]

Amount focus is trying to move

collided__weakhead (where, focus, focusSide, focusVector)

Makes enemy die when character hit it’s top

Parameters

where

gma.constant

Side of this object that was collided with

focus

object

Thing we collided with

focusSide

gma.constant

Side of the focus object that was collided with

focusVector

[x,y]

Amount focus is trying to move