Difference between revisions of "Delayed-Message Action"

From AgentCubes
Jump to navigation Jump to search
imported>Mike
imported>Corrina
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Image:delayed message2.png|150px]]  
+
[[Image:Delayed message action.png|200px|Delayed message.png]]  
  
 
{| width="100%" cellspacing="0" cellpadding="10" border="0"
 
{| width="100%" cellspacing="0" cellpadding="10" border="0"
 
|-
 
|-
 
| width="80" valign="top" align="left" | '''Definition:'''  
 
| width="80" valign="top" align="left" | '''Definition:'''  
| width="100%" valign="top" align="left" | The '''delayed-message''' action will trigger a message in this agent after a specified amount of time. Note that it is not possible to send delayed messages to other agents.&nbsp; <br>
+
| width="100%" valign="top" align="left" | The '''delayed-message''' action: ''will trigger a message in this agent after a specified amount of time. Messages will only be triggered in a running simulation.''&nbsp; <br>
 
|-
 
|-
 
| width="80" valign="top" align="left" | '''Parameters:'''  
 
| width="80" valign="top" align="left" | '''Parameters:'''  
| width="100%" valign="top" align="left" | [[Method parameter|method]], [[Time parameter|time]]
+
| width="100%" valign="top" align="left" |  
 +
[[Method parameter|method]]: ''name of the message''
 +
 
 +
[[Time parameter|time]]: ''how long the delay will last, in seconds.''
 +
 
 
|-
 
|-
 
| width="80" valign="top" align="left" | '''Example 1:'''  
 
| width="80" valign="top" align="left" | '''Example 1:'''  
 
| width="100%" valign="top" align="left" |  
 
| width="100%" valign="top" align="left" |  
'''Move after 2 second: '''This agent has two methods delayed_move and move, when it receives a delayed_move message it will wait 2 second then call its own move method which will move it randomly. &nbsp;  
+
'''Fading shield:'''&nbsp; Imagine you are creating somesort of space based action game where there are obstacles that you must avoid or take damage.&nbsp; In this sort of game you could use the '''delayed message''' action to create a shield which would activae upon a key press condition and which would be set to fade after a certain amount of time with the '''delayed message''' action.&nbsp; In the following image we see a Spaceship agent's behavior.&nbsp; When the user presses the space key and the spaceship is not shielded, it will change to the shielded shape and trigger a delayed message to call "Shields_Fade" in 3 seconds.&nbsp; After three seconds have passed, "Shields_Fade" will be called and the spaceship will change back to its non shielded shape.&nbsp; <br>
  
[[Image:Delayed-message2.png]]  
+
[[Image:Shields.png]]<br>
  
 
<br>  
 
<br>  

Latest revision as of 20:36, 20 April 2012

Delayed message.png

Definition: The delayed-message action: will trigger a message in this agent after a specified amount of time. Messages will only be triggered in a running simulation. 
Parameters:

method: name of the message

time: how long the delay will last, in seconds.

Example 1:

Fading shield:  Imagine you are creating somesort of space based action game where there are obstacles that you must avoid or take damage.  In this sort of game you could use the delayed message action to create a shield which would activae upon a key press condition and which would be set to fade after a certain amount of time with the delayed message action.  In the following image we see a Spaceship agent's behavior.  When the user presses the space key and the spaceship is not shielded, it will change to the shielded shape and trigger a delayed message to call "Shields_Fade" in 3 seconds.  After three seconds have passed, "Shields_Fade" will be called and the spaceship will change back to its non shielded shape. 

Shields.png