Callbacks
μκ°
μ€ν¬λ¦½νΈ κ°λ°μκ° μ§μ ν ν€λ₯Ό νλ μ΄μ΄κ° λλ μ λ λλ μ€ν¬λ¦½νΈ κ°λ°μκ° μ§μ ν μ§μ μ λμ°©νμ λ λ±, 쑰건μ μ€μ νμ¬ νλ μ΄μ΄κ° 쑰건μ λ¬μ±νμ κ²½μ° λμνλ ν¨μλ€ μ λλ€.
runLater
μ§μ ν μκ°(μ΄) ν λμνλ ν¨μ μ λλ€.
addOnTileTouched
μ§μ ν x, y μ’νμ νλ μ΄μ΄κ° λμ°©νμ λ μ€νλλ ν¨μμ λλ€.
addOnLocationTouched
μ§μ ν βμ§μ μμβμ νλ μ΄μ΄κ° λμ°©νμ λ μ€νλλ ν¨μμ λλ€.
addOnKeyDown
νλ μ΄μ΄κ° μ§μ λ ν€λ₯Ό λλ μ λ μ€νλλ ν¨μ μ λλ€.
setTimeout
μ§μ ν μκ°(ms) ν ν¨μλ₯Ό μ€νν©λλ€.
setInterval
μ§μ ν μκ°(ms) κ°κ²©μΌλ‘ ν¨μλ₯Ό μ€νν©λλ€.
addMobileButton
λͺ¨λ°μΌ νκ²½μμ 컀μ€ν λͺ¨λ°μΌ λ²νΌμ μΆκ°νκ³ , λ²νΌμ λλ μ λ λμνλ ν¨μλ₯Ό μ§μ ν©λλ€.
putMobilePunch
λͺ¨λ°μΌ νκ²½μμ νμΉ λ²νΌμ μΆκ°ν©λλ€.
putMobilePunchWithIcon
λ‘λν μ΄λ―Έμ§λ‘ νμΉ λ²νΌμ λ§λ€μ΄ μΆκ°ν©λλ€.
π API μ€λͺ
λ° μμ
Callbacks ν¨μ ν λμ 보기
// time(μ΄) νμ callback ν¨μλ₯Ό μ€ν
App.runLater(callback, time: number)
// νλ μ΄μ΄κ° ν΄λΉ μμΉμ νμΌκ³Ό λΆλͺνμ λ μ€ν
App.addOnTileTouched(x: number, y: number, callback)
// νλ μ΄μ΄κ° μ§μ ν μμΉμ λΆλͺνμ λ μ€ν
App.addOnLocationTouched(name: string, callback)
// νλ μ΄μ΄κ° μ§μ λ ν€λ₯Ό λλ μ λ μ€ν
App.addOnKeyDown(keycode : number, callback);
// time(ms) νμ callback ν¨μλ₯Ό μ€ν
setTimeout(callback, time: number)
// time(ms) ν ν¨μλ₯Ό μ€ν
setInterval(callback, time: number)
// λͺ¨λ°μΌ νκ²½μμ 컀μ€ν
λͺ¨λ°μΌ λ²νΌμ μΆκ°νκ³ , λ²νΌμ λλ μ λ λμνλ ν¨μλ₯Ό μ§μ
App.addMobileButton(anchor: number, posX: number, posY: number, function(player){} )
// λͺ¨λ°μΌ νκ²½μμ νμΉ λ²νΌ μΆκ°/μ κ±°ν©λλ€.
App.putMobilePunch(enable: boolean = true)
// λ‘λν μ΄λ―Έμ§λ‘ νμΉ λ²νΌμ λ§λ€μ΄ μΆκ°ν©λλ€.
App.putMobilePunchWithIcon(icon: ScriptDynamicResource)
runLater
time(μ΄) νμ callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
time
Number
λͺ μ΄ νμ μ€ν λ μ§λ₯Ό μ νλ μκ° (μ΄)
μμ
μ±μ΄ μμλκ³ 5μ΄ ν λ©μμ§ μΆλ ₯ν΄λ³΄κΈ°
App.onStart.Add(function () {
App.runLater(function() {
App.showCenterLabel("λ©μμ§");
}, 5);
});
addOnTileTouched
μ§μ ν x, yμ’νμ νλ μ΄μ΄κ° λμ°©ν κ²½μ° callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
x, y
number
μ§μ ν x, y μ’ν
μμ
νλ μ΄μ΄κ° μ§μ μ’νμ λμ°© νμ λ λ©μμ§ μΆλ ₯ν΄λ³΄κΈ°
// νλ μ΄μ΄κ° 5, 5 μ’νμ λμ°©ν κ²½μ°
App.addOnTileTouched(5, 5, function (player) {
App.showCenterLabel(`${player.name}λμ΄ (5, 5) μ’νμ λμ°©!`);
});
addOnLocationTouched
νλ μ΄μ΄κ° λ§΅μλν°μμ μ§μ ν βμ§μ μμβμ λμ°©νμ λ callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
name
String
λ§΅ μλν°μμ μ§μ ν βμ§μ μμβμ μ΄λ¦
player
Player
μ§μ μμμ λμ°©ν νλ μ΄μ΄λ₯Ό κ°λ₯΄ν΄ νλΌλ―Έν°μ μ΄λ¦μ μμλ‘ μ§μ κ°λ₯
μμ
νλ μ΄μ΄κ° μ§μ μμμ λμ°©νμ λ λ©μμ§ μΆλ ₯ν΄λ³΄κΈ°
// νλ μ΄μ΄κ° μ΄λ¦μ΄ "myLocation"μΈ μμμ λμ°©νμ λ μ€ν
App.addOnLocationTouched("myLocation", function(player){
App.showCenterLabel(`${player.name}λμ΄ myLocationμ λμ°©νμ΅λλ€.`)
});
addOnKeyDown
νλ μ΄μ΄κ° μ§μ λ ν€λ₯Ό λλ μ λ callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
player
Player
ν΄λΉ ν€λ₯Ό λλ₯Έ νλ μ΄μ΄λ₯Ό κ°λ₯΄ν΄ player νλΌλ―Έν° μ΄λ¦μ μμλ‘ λ³κ²½ κ°λ₯
μμ
aλ₯Ό λλ μ λ λ©μμ§ μΆλ ₯ν΄λ³΄κΈ° ( aμ ν€μ½λ: 65 )
// νλ μ΄μ΄κ° aλ₯Ό λλ μ λ μ€ν
App.addOnKeyDown(65, function(player){
App.sayToAll(`${player.name}λμ΄ aν€λ₯Ό λλ μ΅λλ€.`)
});
setTimeout
time(ms) νμ callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
time
Number
callback ν¨μ μ€ν μ λκΈ° μκ° (ms)
μμ
μ±μ΄ μμλκ³ 5μ΄ ν λ©μμ§ μΆλ ₯ν΄λ³΄κΈ°
App.onStart.Add(function () {
setTimeout(function () {
App.sayToAll("5μ΄ν λ©μμ§ μΆλ ₯");
}, 5000);
});
setInterval
time(ms) κ°κ²©μΌλ‘ callback ν¨μλ₯Ό μ€νν©λλ€.
νλΌλ―Έν°
time
Number
callback ν¨μ μ€ν μ£ΌκΈ° (ms)
μμ
μ±μ΄ μμλκ³ 1μ΄ κ°κ²©μΌλ‘ λ©μμ§ μΆλ ₯ν΄λ³΄κΈ°
let time = 0;
App.onStart.Add(function () {
setInterval(function () {
App.sayToAll(`μ± μ€ν ${++time}μ΄ κ²½κ³Ό`);
}, 1000);
});
addMobileButton
λͺ¨λ°μΌ νκ²½μμ 컀μ€ν λͺ¨λ°μΌ λ²νΌμ μΆκ°νκ³ , λ²νΌμ λλ μ λ λμνλ ν¨μλ₯Ό μ§μ ν©λλ€.
λͺ¨λ°μΌλ²νΌμμμ΄λ―Έμ§λ₯Ό μνλ μ΄λ―Έμ§λ‘ λ³κ²½ ν μ μμ΅λλ€.
νλΌλ―Έν°
anchor
Number
λͺ¨λ°μΌ λ²νΌμ μμΉλ₯Ό μ«μλ‘ μ λ ₯ν©λλ€. TOP = 0, TOP_LEFT = 1, TOP_RIGHT = 2, MIDDLE = 3, MIDDLE_LEFT = 4, MIDDLE_RIGHT = 5, BOTTOM = 6, BOTTOM_LEFT = 7, BOTTOM_RIGHT = 8
posX
Number
λͺ¨λ°μΌ λ²νΌ x λ°©ν₯ μ€νμ μμΉ
posY
Number
λͺ¨λ°μΌ λ²νΌ y λ°©ν₯ μ€νμ μμΉ
player
Player
λͺ¨λ°μΌ λ²νΌμ λλ₯Έ νλ μ΄μ΄λ₯Ό κ°λ₯΄ν΄
μμ
λͺ¨λ°μΌ λ²νΌ μΆκ°ν΄λ³΄κΈ°

App.onStart.Add(function () {
// Bottom_Right
App.addMobileButton(8, 145, 75, function (player) {
App.sayToAll(`${player.name}, Bottom λ²νΌA`);
});
// Bottom_Right
App.addMobileButton(8, 145, -20, function (player) {
App.sayToAll(`${player.name}, Bottom λ²νΌB`);
});
// Top
App.addMobileButton(0, 0, 400, function (player) {
App.sayToAll(`${player.name}, TOP λ²νΌ`);
});
// Top_Left
App.addMobileButton(1, 50, 400, function (player) {
App.sayToAll(`${player.name}, TOP_LEFT λ²νΌ`);
});
// Top_right
App.addMobileButton(2, 50, 400, function (player) {
App.sayToAll(`${player.name}, TOP_RIGHT λ²νΌ`);
});
// Middle
App.addMobileButton(3, 0, 100, function (player) {
App.sayToAll(`${player.name}, MIDDLE λ²νΌ`);
});
// Middle_left
App.addMobileButton(4, 50, 100, function (player) {
App.sayToAll(`${player.name}, MIDDLE LEFT λ²νΌ`);
});
// Middle_right
App.addMobileButton(5, 50, 100, function (player) {
App.sayToAll(`${player.name}, MIDDLE RIGHT λ²νΌ`);
});
});
putMobilePunch
enableμ΄ trueμ΄λ©΄ λͺ¨λ°μΌ νκ²½μμ νμΉ λ²νΌμ΄ μΆκ°λ©λλ€.
νλΌλ―Έν°
enable
Boolean
λͺ¨λ°μΌ νμΉ λ²νΌ νμ±ν μ¬λΆ ( κΈ°λ³Έ κ° true )
μμ
Q λ²νΌμ λλ¬ λͺ¨λ°μΌ νκ²½μ νμΉ λ²νΌμ μΆκ°/μ κ±° ν΄λ³΄κΈ°

let punchButton = false;
// Q λ²νΌμ λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81, function (player) {
if (!punchButton) {
punchButton = true;
App.putMobilePunch();
} else {
punchButton = false;
App.putMobilePunch(false);
}
});
putMobilePunchWithIcon
λ‘λν μ΄λ―Έμ§λ‘ νμΉ λ²νΌμ λ§λ€μ΄ μΆκ°ν©λλ€.
νλΌλ―Έν°
icon
ScriptDynamicResource
App.loadSpriteSheet ν¨μλ‘ λ‘λν μ΄λ―Έμ§ 리μμ€
μμ
Q λ²νΌμ λλ¬ λͺ¨λ°μΌ νκ²½μ λ‘λν μ΄λ―Έμ§λ‘ νμΉ λ²νΌ μΆκ°νκΈ°


const punchIcon = App.loadSpritesheet("punchIcon.png")
// Q λ²νΌμ λλ₯΄λ©΄ λμνλ ν¨μ
App.addOnKeyDown(81, function (player) {
App.putMobilePunchWithIcon(punchIcon);
});
λΆλ‘
Last updated
Was this helpful?