Event Listeners

์†Œ๊ฐœ

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ง€์ •๋œ ์ฑ„ํŒ…์„ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜, ํŠน์ •ํ•œ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ์™€ ๊ฐ™์ด ZEP ์ŠคํŽ˜์ด์Šค์—์„œ ๋ฐœ์ƒํ•˜๋Š” ํŠน์ • ์ƒํ™ฉ์— ๋ฐ˜์‘ํ•˜์—ฌ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜๋“ค ์ž…๋‹ˆ๋‹ค.

EventListener๊ฐ€ ๋น„์ •์ƒ์ ์œผ๋กœ ๋งŽ์ด ์ถ”๊ฐ€๋˜๋Š” ๊ฒฝ์šฐ ์•ฑ์ด ์ข…๋ฃŒ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

onUpdate๋ฌธ ๋˜๋Š” ๋ฐ˜๋ณต์ ์œผ๋กœ ์‹คํ–‰๋˜๋Š” ๋ฌธ์—์„œ EventListener๋ฅผ ๋“ฑ๋กํ•˜๋Š” ๊ฒƒ์„ ์ง€์–‘ํ•ด์ฃผ์„ธ์š”.

์ด๋ฆ„์„ค๋ช…

onSay

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ฑ„ํŒ…์„ ์ž…๋ ฅํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onPlayerTouched

์บ๋ฆญํ„ฐ๋“ค๋ผ๋ฆฌ ์ถฉ๋Œํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onObjectTouched

์บ๋ฆญํ„ฐ๊ฐ€ ์˜ค๋ธŒ์ ํŠธ์™€ ์ถฉ๋Œํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onAppObjectTouched

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ์™€ ์ถฉ๋Œํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onUnitAttacked

๊ณต๊ฒฉ ํ‚ค(Z)๋กœ ๋‹ค๋ฅธ ์บ๋ฆญํ„ฐ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onObjectAttacked

๊ณต๊ฒฉ ํ‚ค(Z)๋กœ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onSidebarTouched

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์‚ฌ์ด๋“œ๋ฐ” ์•ฑ์„ ํด๋ฆญ(ํ„ฐ์น˜)ํ•  ๋•Œ ์‹คํ–‰๋˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onTriggerObject

์˜ค๋ธŒ์ ํŠธ์™€ F ์ƒํ˜ธ์ž‘์šฉ ์‹œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

onAppObjectAttacked

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉ(Zํ‚ค) ํ•  ๋•Œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค.

๐Ÿ“š API ์„ค๋ช… ๋ฐ ์˜ˆ์ œ

Event Listener ํ•จ์ˆ˜ ํ•œ ๋ˆˆ์— ๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๋“ค์ด ์ฑ„ํŒ…์ฐฝ์— ์ž…๋ ฅํ•˜๋Š” ๋ชจ๋“  ์ฑ„ํŒ…์— ๋Œ€ํ•ด ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
// !๋กœ ์‹œ์ž‘ํ•˜๋Š” ํ…์ŠคํŠธ๋Š” ์ฑ„ํŒ…์ฐฝ์— ๋‚˜์˜ค์ง€ ์•Š์œผ๋‚˜, onSay ํ•จ์ˆ˜์—๋Š” ์‚ฌ์šฉ ๊ฐ€๋Šฅ
App.onSay.Add(function(player, text) {
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋‹ค๋ฅธ ํ”Œ๋ ˆ์ด์–ด์™€ ๋ถ€๋”ชํ˜”์„ ๋•Œ ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onPlayerTouched.Add(function(sender, target, x, y){
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์˜ค๋ธŒ์ ํŠธ์™€ ๋ถ€๋”ชํ˜”์„ ๋•Œ ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onObjectTouched.Add(function(sender, x, y, tileID, obj) {  
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ์™€ ๋ถ€๋”ชํ˜”์„ ๋•Œ ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onAppObjectTouched.Add(function(key, sender, x, y){});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๋‹ค๋ฅธ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ (Zํ‚ค) ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onUnitAttacked.Add(function(sender, x, y, target) {
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉ(Zํ‚ค)ํ–ˆ์„ ๋•Œ ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onObjectAttacked.Add(function(sender, x, y){
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์‚ฌ์ด๋“œ๋ฐ” ์•ฑ์„ ํด๋ฆญ(ํ„ฐ์น˜)ํ•  ๋•Œ ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onSidebarTouched.Add(function(player){
}); 

// ์˜ค๋ธŒ์ ํŠธ์™€ F ์ƒํ˜ธ์ž‘์šฉ ์‹œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜
App.onTriggerObject.Add(function(player, layer, x, y){
});

// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ (Zํ‚ค) ํ˜ธ์ถœ ๋˜๋Š” ์ด๋ฒคํŠธ
App.onAppObjectAttacked.Add(function (sender, x, y, layer, key) {
});

onSay

App.onSay.Add(function(player, text){});

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ฑ„ํŒ…์„ ์ž…๋ ฅํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

player

Player

player ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ์ฑ„ํŒ…์„ ์ž…๋ ฅํ•œ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด player ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„์€ ์ž„์˜๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

text

String

text๋Š” ์ž…๋ ฅํ•œ ์ฑ„ํŒ… ๋‚ด์šฉ์„ ๊ฐ€๋ฅดํ‚ด text ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„์€ ์ž„์˜๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

์˜ˆ์ œ

์ดˆ์„ฑํ€ด์ฆˆ - ์ฑ„ํŒ…์œผ๋กœ ์ •๋‹ต ๋งž์ถ”๋Š” ๊ธฐ๋Šฅ ๋งŒ๋“ค์–ด๋ณด๊ธฐ

_answer = "ZEP" // ์ •๋‹ต
// ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์ฑ„ํŒ…์„ ์น  ๋•Œ ์‹คํ–‰
App.onSay.add(function(player, text) {
    if(_answer == text){
        App.showCenterLabel(player.name + '๋‹˜ ์ •๋‹ต!\n์ •๋‹ต์€ ' + _answer);
    }
});

onPlayerTouched

App.onPlayerTouched.Add(function(sender, target, x, y){});

์บ๋ฆญํ„ฐ๋“ค๋ผ๋ฆฌ ์ถฉ๋Œํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ๋ถ€๋”ชํžŒ ์ฃผ์ฒด์ž๋ฅผ ๊ฐ€๋ฅดํ‚ด

target

String

target์€ ๋ถ€๋”ชํž˜์„ ๋‹นํ•œ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

x, y

Number

x, y๋Š” ์ถฉ๋Œํ•œ x, y ์ขŒํ‘œ๋ฅผ ๊ฐ€๋ฅดํ‚ด

sender, target, x, y ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„์€ ์ž„์˜๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

์˜ˆ์ œ

์บ๋ฆญํ„ฐ๋ผ๋ฆฌ ๋ถ€๋”ชํž ๋•Œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

// ํ”Œ๋ ˆ์ด์–ด๋ผ๋ฆฌ ๋ถ€๋”ชํž ๋•Œ ์‹คํ–‰
App.onPlayerTouched.Add(function (sender, target, x, y) {
	App.showCenterLabel(
		`${sender.name}๋‹˜๊ณผ ${target.name}๋‹˜์ด ์ขŒํ‘œ: (${x}, ${y}) ์—์„œ ๋ถ€๋”ชํ˜”์Šต๋‹ˆ๋‹ค.`
	);
});

onObjectTouched

App.onObjectTouched.Add(function(sender, x, y, tileID, obj){});

์บ๋ฆญํ„ฐ๊ฐ€ ์˜ค๋ธŒ์ ํŠธ์™€ ์ถฉ๋Œ ๋˜๋Š” ์ƒํ˜ธ์ž‘์šฉ ํ•  ๋•Œ ํ•œ ๋ฒˆ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ์˜ค๋ธŒ์ ํŠธ์™€ ๋ถ€๋”ชํžŒ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

x, y

Number

์˜ค๋ธŒ์ ํŠธ์™€์ถฉ๋Œํ•œ x, y ์ขŒํ‘œ๋ฅผ ๊ฐ€๋ฅดํ‚ด

tileID

Number

์˜ค๋ธŒ์ ํŠธ์˜ ํƒ€์ผ ID ์ž…๋‹ˆ๋‹ค.

obj

Object

์˜ค๋ธŒ์ ํŠธ ๊ฐ์ฒด

์˜ˆ์ œ

โญ overlap: true ์†์„ฑ์ด ์—†๋Š” ์˜ค๋ธŒ์ ํŠธ๋Š” ์ถฉ๋Œํ•ด๋„ ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

let testObject = App.loadSpritesheet("object.png");
// ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ObjectEffectType
const ObjectEffectType = {
    NONE = 0,
    SHOW_NOTE = 1,
    SHOW_IMAGE = 2,
    PASSWORD_DOOR = 3,
    LINK_WEBSITE = 4,
    EMBED_WEBSITE = 5,
    API_CALL = 6,
    REPLACE_IMAGE = 7,
    NFT_GIVEAWAY = 8,
    NFT_DOOR = 9,
    POST_MESSAGE = 10,
    SHOW_CHAT_BALLOON = 11,
    FT_DOOR = 12,
    POST_MESSAGE_TO_APP = 13,
    DONATION_DOOR = 14,
    IMPASSABLE = 15,
    STAMP = 16,
    TOKEN_DONATION_DOOR = 17,
    CHANGE_OBJECT = 18,
    ANIMATION = 19,
    NFT_DOOR_MOVE = 20,
    INTERACTION_WITH_ZEPSCRIPTS = 21,
    MULTIPLE_CHOICE = 22,
}

App.onStart.Add(function () {
	Map.putObject(5, 5, testObject, { overlap: true });
});

// ํ”Œ๋ ˆ์ด์–ด์™€ ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ๋ถ€๋”ชํž ๋•Œ ์‹คํ–‰
App.onObjectTouched.Add(function (sender, x, y, tileID, obj) {
	Map.putObject(x, y, null);
	App.showCenterLabel(
		`${sender.name}๋‹˜์ด ์ขŒํ‘œ: (${x}, ${y}) ์—์„œ ์˜ค๋ธŒ์ ํŠธ์™€ ๋ถ€๋”ชํ˜”์Šต๋‹ˆ๋‹ค.(ํƒ€์ž…: ${obj.type})`
	);
});

onAppObjectTouched

App.onAppObjectTouched.Add(function(sender, key, x, y){});

๏ธ ์บ๋ฆญํ„ฐ๊ฐ€ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ์™€ ์ถฉ๋Œํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ์˜ค๋ธŒ์ ํŠธ์™€ ๋ถ€๋”ชํžŒ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

key

String

์˜ค๋ธŒ์ ํŠธ์˜ Key ๊ฐ’

x, y

Number

x, y๋Š” ์ถฉ๋Œํ•œ x, y ์ขŒํ‘œ๋ฅผ ๊ฐ€๋ฅดํ‚ด

์˜ˆ์ œ

๋ผ๋ฒจ ์ถœ๋ ฅ ์˜ˆ์ œ

โญ overlap: true ์†์„ฑ์ด ์—†๋Š” ์˜ค๋ธŒ์ ํŠธ๋Š” ์ถฉ๋Œํ•ด๋„ ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

let blueman_dance = App.loadSpritesheet(
	"blueman.png",
	48,
	64,
	[20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37],
	8
);

// Q๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋™์ž‘ ํ•˜๋Š” ํ•จ์ˆ˜
App.addOnKeyDown(81, function (player) {
	App.sayToAll("ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ ์ถฉ๋Œ ํ…Œ์ŠคํŠธ");
	Map.putObjectWithKey(8, 5, blueman_dance, { overlap: true, key: "blueman" });
});

App.onAppObjectTouched.Add(function (player, key, x, y) {
	App.sayToAll(
		`${player.name}์ด ํ‚ค ๊ฐ’์ด ${key}์ธ ์˜ค๋ธŒ์ ํŠธ์™€ ${x},${y}์—์„œ ์ถฉ๋Œ!`
	);
});

onUnitAttacked

App.onUnitAttacked.Add(function(sender, x, y, target){});

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ณต๊ฒฉ ํ‚ค(Z)๋กœ ๋‹ค๋ฅธ ์บ๋ฆญํ„ฐ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ๊ณต๊ฒฉํ•œ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

x, y

Number

x, y๋Š” ๊ณต๊ฒฉํ•œ ํ”Œ๋ ˆ์ด์–ด์˜ x, y ์ขŒํ‘œ ๊ฐ’์„ ๊ฐ€๋ฅดํ‚ด

target

Player

target์€ ๊ณต๊ฒฉ ๋ฐ›์€ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

sender, x, y, target ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„์€ ์ž„์˜๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

์˜ˆ์ œ

ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ณต๊ฒฉ ํ•  ๋•Œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

// Z ํ‚ค๋กœ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ์‹คํ–‰
App.onUnitAttacked.Add(function (sender, x, y, target) {
	App.showCenterLabel(`${sender.name}๋‹˜์ด ${target.name}๋‹˜์„ ๊ณต๊ฒฉํ–ˆ์Šต๋‹ˆ๋‹ค.`);
	App.sayToAll(`(${x}, ${y})`);
});

onObjectAttacked

App.onObjectAttacked.Add(function(sender, x, y){});

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ณต๊ฒฉ ํ‚ค(Z)๋กœ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ๊ณต๊ฒฉํ•œ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

x, y

Number

x, y๋Š” ์˜ค๋ธŒ์ ํŠธ์˜ x, y ์ขŒํ‘œ ๊ฐ’์„ ๊ฐ€๋ฅดํ‚ด

sender, x, y ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ์ด๋ฆ„์€ ์ž„์˜๋กœ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅ

์˜ˆ์ œ

์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

โญ overlap: true ์†์„ฑ์ด ์—†๋Š” ์˜ค๋ธŒ์ ํŠธ๋Š” ๊ณต๊ฒฉํ•ด๋„ ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

let testObject = App.loadSpritesheet("object.png");

App.onStart.Add(function () {
	Map.putObject(5, 5, testObject, { overlap: true });
});
// Z ํ‚ค๋กœ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ์‹คํ–‰
App.onObjectAttacked.Add(function(sender, x, y){
	App.showCenterLabel(
		`${sender.name}๋‹˜์ด ์ขŒํ‘œ: (${x}, ${y})์— ์œ„์น˜ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ–ˆ์Šต๋‹ˆ๋‹ค.`
	);
})

onSidebarTouched

App.onSidebarTouched.Add(function(player){});

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ์‚ฌ์ด๋“œ๋ฐ” ์•ฑ์„ ํด๋ฆญ(ํ„ฐ์น˜) ํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

player

Player

์‚ฌ์ด๋“œ๋ฐ” ์•ฑ์„ ํด๋ฆญํ•œ player๋ฅผ ๊ฐ€๋ฅดํ‚ด

์˜ˆ์ œ

์‚ฌ์ด๋“œ๋ฐ” ์•ฑ ํด๋ฆญ ์‹œ ์ฑ„ํŒ…์ฐฝ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•˜๊ธฐ.

App.onSidebarTouched.Add(function (player) {
	App.sayToAll(`${player.name}๋‹˜์ด ์‚ฌ์ด๋“œ๋ฐ” ์•ฑ์„ ํด๋ฆญํ–ˆ์Šต๋‹ˆ๋‹ค.`)
});

๊ด€๋ จ ํŽ˜์ด์ง€

์‚ฌ์ด๋“œ๋ฐ” ์•ฑ ์˜ˆ์ œ

onTriggerObject

App.onTriggerObject.Add(function(player, layerID, x, y, key){});

์˜ค๋ธŒ์ ํŠธ์™€ F ์ƒํ˜ธ์ž‘์šฉ ์‹œ ๋™์ž‘ํ•˜๋Š” ํ•จ์ˆ˜๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋งต์—๋””ํ„ฐ๋กœ ์„ค์น˜ํ•œ ์˜ค๋ธŒ์ ํŠธ ๋˜๋Š” ์Šคํฌ๋ฆฝํŠธ์—์„œ type์„ INTERACTION_WITH_ZEPSCRIPTS(21)๋กœ ์„ค์น˜ํ•œ ์˜ค๋ธŒ์ ํŠธ์™€ ์ƒํ˜ธ์ž‘์šฉ ์‹œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

player

Player

์˜ค๋ธŒ์ ํŠธ์™€ ์ƒํ˜ธ์ž‘์šฉํ•œ player๋ฅผ ๊ฐ€๋ฅดํ‚ด

layerID

Number

์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์„ค์น˜๋œ ๋ ˆ์ด์–ด ID ์˜ค๋ธŒ์ ํŠธ์ธ ๊ฒฝ์šฐ layerID = 3 ์ƒ๋‹จ ์˜ค๋ธŒ์ ํŠธ์ธ ๊ฒฝ์šฐ layerID = 5

x, y

Number

์ƒํ˜ธ์ž‘์šฉํ•œ ์˜ค๋ธŒ์ ํŠธ์˜ x, y ์ขŒํ‘œ

key

String

์ƒํ˜ธ์ž‘์šฉํ•œ ์˜ค๋ธŒ์ ํŠธ์˜ key ๊ฐ’

์˜ˆ์ œ

์˜ค๋ธŒ์ ํŠธ์™€ F ์ƒํ˜ธ์ž‘์šฉ์‹œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•˜๊ธฐ

let blueman = App.loadSpritesheet("blueman.png");

App.onJoinPlayer.Add(function (player) {
	Map.putObjectWithKey(player.tileX + 1, player.tileY, blueman, {
		type: ObjectEffectType.INTERACTION_WITH_ZEPSCRIPTS,
		impassable: true,
		key: "objectKey",
	});
});


App.onTriggerObject.Add(function (player, layerID, x, y, key) {
	App.sayToAll(`playerName: ${player.name} / layer: ${layerID} / coordinates:(${x}, ${y}) / key: ${key}`);
});

onAppObjectAttacked

App.onAppObjectAttacked.Add(function (sender, x, y, layer, key) {});

ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ๊ณต๊ฒฉ ํ‚ค(Z)๋กœ ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.

๊ด€๋ จ ๋ฌธ์„œ: ์˜ค๋ธŒ์ ํŠธ npcProperty

ํŒŒ๋ผ๋ฏธํ„ฐ

์ด๋ฆ„ํƒ€์ž…์„ค๋ช…

sender

Player

sender๋Š” ๊ณต๊ฒฉํ•œ ํ”Œ๋ ˆ์ด์–ด๋ฅผ ๊ฐ€๋ฅดํ‚ด

x, y

Number

x, y๋Š” ์˜ค๋ธŒ์ ํŠธ์˜ x, y ์ขŒํ‘œ ๊ฐ’์„ ๊ฐ€๋ฅดํ‚ด

layer

Number

์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์„ค์น˜๋œ ๋ ˆ์ด์–ด

key

String

๊ณต๊ฒฉํ•œ ์˜ค๋ธŒ์ ํŠธ์˜ ํ‚ค ๊ฐ’

์˜ˆ์ œ

ํ‚ค ๊ฐ’์„ ๊ฐ€์ง„ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๊ณต๊ฒฉํ•  ๋•Œ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅํ•ด๋ณด๊ธฐ

โญ collide: true ์†์„ฑ์ด ์—†๋Š” ํ‚ค ๊ฐ’ ์˜ค๋ธŒ์ ํŠธ๋Š” ๊ณต๊ฒฉํ•ด๋„ ํ•จ์ˆ˜๊ฐ€ ์‹คํ–‰๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

App.onAppObjectAttacked.Add(function (sender, x, y, layer, key) {
    App.showCenterLabel(
        `sender: ${sender.name} 
        coordinates: (${x}, ${y})
        layer: ${layer}
        key: ${key}`
    );
});

๊ด€๋ จ ํŽ˜์ด์ง€

์‚ฌ์ด๋“œ๋ฐ” ์•ฑ ์˜ˆ์ œ

Last updated