OGWPlatformerCommandsAspect Class Reference
Inherits from | OGWAspect : NSObject |
Conforms to | OGWUpdateableAspect |
Declared in | OGWPlatformerCommandsAspect.h |
Overview
Platformer commands and view delegation aspect.
Requests first check the current game state before executing (or ignoring) the command. For example you can request to jump in mid-air, which will be ignored. All commands should be issued through requests that perform such validity checks.
If a request is successful (or if it is unsuccessful, as needed) the command aspect will send a corresponding message to the view delegate. Thus the view can request the initiation of a jump but it has to wait for the entityDidJump message before it can play the jump animation and sound. The view should only ever request an action, and respond to successful execution (or not) of such events, therefore separating the view code into event delivery and reacting to state changes while also reducing the amount of view code to write.
Other messages are received on certain events and execute actions directly and with little checks. These methods provide the normal flow of routine, for example killing, moving to checkpoint, and respawning the entity - but usually initiated through one of the “should” commands, in this example via the entityShouldDie method. These methods are purposefully not in the class reference here but you’ll find them documented in the class header.
Tasks
Requests
-
– entityShouldJump
-
– entityShouldEndJump
-
– entityShouldMoveLeft
-
– entityShouldMoveRight
-
– entityShouldStopMovingAlongXAxis
-
– entityShouldTeleportToCheckpointWithName:
-
– entityShouldTakeDamage:
-
– entityShouldDie
-
– entityShouldDieWithReason:
-
– entityShouldRespawnAtCheckpoint
Events (not to be used by the view)
Instance Methods
entityShouldDie
Request the entity should die with no specific reason.
- (void)entityShouldDie
Declared In
OGWPlatformerCommandsAspect.h
entityShouldDieWithReason:
Request the entity should die with a specific reason.
- (void)entityShouldDieWithReason:(OGWPlatformerStateChangeReason)reason
Parameters
- reason
The cause of death as defined in OGWPlatformerStateChangeReason
Declared In
OGWPlatformerCommandsAspect.h
entityShouldEndJump
Request the entity to end a current jump. If ending the jump was possible, entityDidEndJump will be sent to view delegate.
- (void)entityShouldEndJump
Declared In
OGWPlatformerCommandsAspect.h
entityShouldJump
Request the entity to jump. If jump was possible, entityDidJump will be sent to view delegate.
- (void)entityShouldJump
Declared In
OGWPlatformerCommandsAspect.h
entityShouldMoveLeft
Request the entity to move left. On success entityDidStartWalkingLeft will be sent to view delegate.
- (void)entityShouldMoveLeft
Declared In
OGWPlatformerCommandsAspect.h
entityShouldMoveRight
Request the entity to move right. On success entityDidStartWalkingRight will be sent to view delegate.
- (void)entityShouldMoveRight
Declared In
OGWPlatformerCommandsAspect.h
entityShouldRespawnAtCheckpoint
Request the entity to respawn at the most recently activated checkpoint, respectively the world’s spawn point if no checkpoint was activated yet.
- (void)entityShouldRespawnAtCheckpoint
Declared In
OGWPlatformerCommandsAspect.h
entityShouldStopMovingAlongXAxis
Request the entity to stop moving horizontally. On success entityDidStopWalking will be sent to view delegate.
- (void)entityShouldStopMovingAlongXAxis
Declared In
OGWPlatformerCommandsAspect.h
entityShouldTakeDamage:
Request the entity should take damage. Currently any amount of damage means death.
- (void)entityShouldTakeDamage:(GWFloat)damageAmount
Parameters
- damageAmount
How much damage to subtract from entity’s health.
Declared In
OGWPlatformerCommandsAspect.h
entityShouldTeleportToCheckpointWithName:
Request the entity to teleport to a checkpoint.
- (void)entityShouldTeleportToCheckpointWithName:(NSString *)checkpointName
Parameters
- checkpointName
The name of a checkpoint. A checkpoint is an entity which has a corresponding string in its values for the OGWPlatformerValueKeyName key.
Declared In
OGWPlatformerCommandsAspect.h