[Basic Type](../groups/Basic Type.Basic Type.md) / Action1
Action1<T> Class
Proxy for a parameter
Usage example: proxy with one parameter
ts
@Component
export default class ActionExample extends Script {
private readonly action1:Action1<player> = new Action1();
protected onStart(): void {
// Add listening for Action1
const id = this.action1.add((player: player) => {
if(player.age < 18) {
console.log("sorry , only those over 18 years old can enter")
} else {
// Specific achieve logic can be developed for the player
player.game();
}
});
InputUtil.onKeyDown(Keys.One, () => {
let playerOne : multiPlayer = new multiPlayer(10.5,"Janny");
this.action1.call(playerOne);
});
}
}
class player
{
public age:number = 2;
public name:string = "Li";
constructor(age: number, name: string) {
this.age = age;
this.name = name;
}
public game(){
console.log("player is playing game");
}
}
class lowPlayer extends player
{
public game(): void {
console.log("lowplayer is playing game");
}
}
class multiPlayer extends player
{
public game(): void {
console.log("multiPlayer is playing game");
}
}
@Component
export default class ActionExample extends Script {
private readonly action1:Action1<player> = new Action1();
protected onStart(): void {
// Add listening for Action1
const id = this.action1.add((player: player) => {
if(player.age < 18) {
console.log("sorry , only those over 18 years old can enter")
} else {
// Specific achieve logic can be developed for the player
player.game();
}
});
InputUtil.onKeyDown(Keys.One, () => {
let playerOne : multiPlayer = new multiPlayer(10.5,"Janny");
this.action1.call(playerOne);
});
}
}
class player
{
public age:number = 2;
public name:string = "Li";
constructor(age: number, name: string) {
this.age = age;
this.name = name;
}
public game(){
console.log("player is playing game");
}
}
class lowPlayer extends player
{
public game(): void {
console.log("lowplayer is playing game");
}
}
class multiPlayer extends player
{
public game(): void {
console.log("multiPlayer is playing game");
}
}
Type parameters
Name |
---|
T |
Hierarchy
↳
Action1
Table of contents
Accessors
Methods
click
Methods
add(fn : Function , thisArg? : any ): number other |
---|
Add a listening method |
call(...params : any ): void other |
implement |
clear(): void other |
Clear all listening |
includes(fn : Function , thisArg : any ): boolean other |
Determine whether a certain listening method is included |
remove(fn : number Function , thisArg? : any ): void other |
Remove a listening method |