Appearance
objectsMoving
- Since: v4.1.0
- Property:
objectsMoving
- Type:
Observable<{ [key: string]: object }>
- Optional:
true
- Read Only
- Usage:
Listen to the movement of objects on stage
valuesChange
- Property:
valuesChange
- Type:
Observable<{ data: object, partial: object }>
- Optional:
true
- Read Only
- Usage:
Listen to all the synchronized values of the scene with the server
ts
import { RpgClient, RpgModule, RpgSceneMap } from '@rpgjs/client'
@RpgModule<RpgClient>({
scenes: {
map: {
onAfterLoading(scene: RpgSceneMap) {
scene.valuesChange.subscribe((obj) => {
console.log(obj.data, obj.partial)
})
}
}
}
})
export default class RpgClientModuleEngine {}
data
represents all the current data of the scene (users
,events
and others)partial
represents only the data that has changed on the scene
In the class, you can also use the onChanges hook
Show Animation
- Method:
scene.showAnimation(object)
- Arguments:
- {
object
}object
. (Optional:false
)
- {
- Return:
Animation
- Usage:
Display an animation on the scene
The object is the following:
graphic
: Spritesheet idanimationName
: The name of the animationattachTo
: Define a sprite. The animation will follow this sprite (optional)x
: Position X (0 by default)y
: Position Y (0 by default)loop
: Display the animation in a loop (false by default)
ts
import { RpgClient, RpgModule, RpgSceneMap } from '@rpgjs/client'
@RpgModule<RpgClient>({
scenes: {
map: {
onAfterLoading(scene: RpgSceneMap) {
const animation = scene.showAnimation({
graphic: 'my-spritesheet',
animationName: 'my-anim'
})
}
}
}
})
export default class RpgClientModuleEngine {}
The return is an animation containing two methods:
play()
: Play the animation (Already the case when calling the method)stop()
: Stop the animation
They have a hook:
onFinish
: Triggered when the animation is finished
ts
animation.onFinish = () => {
console.log('finish !')
}
Get Sprite
- Method:
scene.getSprite(id)
- Arguments:
- {
string
}id
. (Optional:false
)
- {
- Return:
RpgSprite | undefined
- Usage:
Retrieve a sprite according to its identifier
Get Current Player
- Method:
scene.getCurrentPlayer()
- Return:
RpgSprite | undefined
- Usage:
Retrieve a sprite that the player controls