Skip to content

SaFrMo/phaser-link

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

What

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.

How

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
}))

API

new Link( { options } )

options

collideWorldBounds

Type: boolean
Default: false

Whether or not the link collides with the world bounds.

controls

Type: boolean
Default: false

Whether or not the link can be controlled by the player.

frame

Type: string | number
Default: ''

See Sprite docs.

game

Required
Type: Phaser.Game

The game where this link will live.

health

Type: number
Default: 1

This link's starting health.

height

Type: number
Default: 64

This link's height.

key

Type: string | Phaser.RenderTexture | Phaser.BitmapData | PIXI.Texture
Default: ''

See Sprite docs.

matchDiagonalSpeed

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.

speed

Type: number
Default: 350

The speed of the link.

width

Type: number
Default: 64

This link's width.

x

Type: number
Default: 0

The x-value of the link's spawn location.

y

Type: number
Default: 0

The y-value of the link's spawn location.

Properties

state

Type: Phaser.State

Shortcut to the current state object. Useful for accessing global properties from that state.

About

Link (Legend of Zelda)-like class for Phaser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published