This is an archive. | |
See the new ClickWiki at https://clickwiki.github.io. This version is just an archive for the purposes of migrating content to the new structure. |
Player Object
Author | |
Status | Released |
Release Date | Unknown |
Available for | Not yet documented |
Supported Runtimes | |
License | Free |
Download | |
---|---|
Includes Examples | No |
Includes Help Files | Yes |
Links | Included by default. |
The Player object governs the use of the joystick and lets you set, add to, and subtract from a player's lives and score. The Player object can read the state of the joystick; perform specific actions, such as end the game, when the player's score is 0 or the player runs out of lives; and remove or restore control to the user.
Note: there can be up to four players objects, assigned to player 1, 2, 3 and 4. Clickteam Fusion 2.5 inspects the movement properties of the objects present in the frame, and automatically detects when a movement is assigned to player 2, 3 or 4. You may want to have player 2 or more present in the event editor without a specific object: just create a dummy object out of the frame of your game and assign player 2 (or more) to it: it will force the display of the player 2 object in the event editor.
The Player object is a system object and is only available in the Event editor.
Contents
Conditions
Joystick
The Joystick conditions read the current state of the joystick. The Joystick conditions are
Read joystick state
Reads the current state of the joystick. For example, the joystick is in the upper, left position with the fire button depressed.
Repeat while joystick pressed
Continually reads the current state of the joystick and repeats the specified action until the state of the joystick changes.
Compare To Player's Score
The Compare To Player's Score condition compares the player's score to another value.
Compare To Player's Number Of Lives
The Compare To Player's Number Of Lives condition compares the player's number of lives to another value.
When Number Of Lives Reaches 0
The When Number Of Lives Reaches 0 condition tests to see if the player's number of lives is 0.
Actions
Score
The Score actions set, add to, and subtract from the score displayed in the Score object. The Score actions are
Set score
Sets the player's score.
Add to score
Adds to the score displayed in the Score object. You can add a number or a variable retrieved from another object.
Subtract from score
Subtracts a numerical value from the score displayed in the Score object.
Number Of Lives
The Number Of Lives actions set, add to, and subtract from the number of lives in the Lives object. The Number Of Lives actions are
Set number of lives
Sets the number of lives that a player has.
Add to number of lives
Adds to the number of lives displayed in the Lives object. You can add a number or a variable retrieved from another object.
Subtract from number of lives
Subtracts a numerical value from the number of lives displayed in the Lives object.
Player Control
The Player Control actions let you ignore or restore player input into the application.
Ignore control
Makes the application ignore player input in the form of joystick input and keyboard direction control input. This action only disables the keys used as direction control.
Restore control
Restores player input if the "Ignore control" action has been previously used.
Set input device
This action and the next one are designed to allow you to create your own player configuration screen. Set input device allow you to choose the input device used by the player, being the keyboard, joystick 1 or joystick 2.
Set key
This action allows you to configure the keyboard for your player. You specify for each entry (up, down, left, right, fire) the key assigned.
Set Player Name
The Set Player Name action allows you to give a name to the player. This name is not displayed. You can retrieve it with the Get Player Name function.
Expressions
Note: The code examples below are for Player 1. Change the player number if necessary.
Current Value Of Score
score( "Player 1" )
The Current Value Of Score function retrieves the current value of a specific player's score.
Current Number Of Lives
lives( "Player 1" )
The Current Number Of Lives function retrieves the current number of lives that a specific player has.
Player Name
playername$( "Player 1" )
The Player Name function retrieves the name of a specific player.
Current input device
input( "Player 1" )
This function is to be used in a player input configuration screen, along with the actions designed for it. It returns the number of the device currently assigned to the player. The return value is a number between 0 (keyboard), 1 (joystick 1) and 2 (joystick 2).
Current key
key$( "Player 1", >Enter key value< )
This function allows you to retrieve which keyboard key is assigned to which direction. You have to enter the direction as a parameter, a number between 0 and 7, 0=up, 1=down, 2=left, 3=right, 4=fire1, 5=fire 2, 6=fire 3, 7=fire 4. The function returns a string containing the current key assigned.