This is part of the Phaser Component Library.
A "link" is a player-controlled character than can move on the X and Y axes. It is not affected by gravity, has a given amount of health, uses arrow keys to move, and does not bind the camera to its movement. Based on Link from the Legend of Zelda games.
npm install phaser-link
Then, in your Phaser source code
import Link from 'phaser-link'
// in your game creation method:
this.game.physics.startSystem( Phaser.Physics.ARCADE )
// add a controllable (arrow keys) Link-like player character
const link = this.game.add.existing(new Link({
game: this.game,
key: 'your-sprite-key',
controls: true
}))
Type: boolean
Default: false
Whether or not the link collides with the world bounds.
Type: boolean
Default: false
Whether or not the link can be controlled by the player.
Type: string | number
Default: ''
See Sprite docs.
Required
Type: Phaser.Game
The game where this link will live.
Type: number
Default: 1
This link's starting health.
Type: number
Default: 64
This link's height.
Type: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture
Default: ''
See Sprite docs.
Type: boolean
Default: true
Forces the link's diagonal speed to match its straight-line speed.
The vector of a link's diagonal movement will have a magnitude greather than its speed, making the link move faster diagonally than it moves in a straight line. Set this value to true
or leave as-is to prevent this behavior.
Type: number
Default: 350
The speed of the link.
Type: number
Default: 64
This link's width.
Type: number
Default: 0
The x-value of the link's spawn location.
Type: number
Default: 0
The y-value of the link's spawn location.
Type: Phaser.State
Shortcut to the current state object. Useful for accessing global properties from that state.