ZEP Guidebook (KR)
  • 👋Hello ZEP Script
  • ZEP Script 가이드
    • ZEP Script 개발 가이드
      • 쉬운 개발 가이드
      • Javascript 개발 가이드
      • Typescript 개발 가이드
      • ZEP Script 배포 가이드
    • ZEP Script 따라하기
      • 기초 예제 코드
        • ✉️메시지 출력해보기
        • ♻️ZEP APP lifecycle 이해하기
        • 👤캐릭터 이미지 바꾸기
        • 🖼️나만의 UI 만들기
        • 💢2초 스턴 효과 만들어보기
      • ZEP Script 예제 코드
        • ⏰타이머
        • ⏱️방탈출 타이머
        • 🤛사이드바 앱
        • 🧟‍♂️좀비 게임
        • 🎨페인트맨 게임
        • 🙆‍♀️초성 퀴즈
        • 💩똥피하기 게임
        • 🥊결투 게임
        • 🏃‍♂️달리기
      • Custom Label 예제 코드
        • Type-A
        • Type-B
        • Type-C
        • Type-D
        • Type-E
        • Type-F
        • Type-G
        • Type-H
        • Type-I
        • Type-J
      • 사이드 바 앱 예제 코드
        • 🔹Image List
        • 🔹Text List
        • 🔹Text Button List
        • 🔹Ranking List
        • 🔹Select List
    • ZEP Script FAQ
    • 부록
      • 🎡ZEP 스크립트 활용 사례
      • 🗺️스페이스와 맵 이해하기
      • ⌨️자바스크립트 키코드 표
      • 🎨스프라이트시트 이해하기
      • 🌀TileEffectType 상세 설명
      • 📌기준 좌표
      • 🛰️외부 API 통신하기
      • 🔰URL 쿼리스트링 활용하기
      • 🪧위젯에서 사용가능한 문법
      • 🔘모바일버튼 이미지 변경하기
      • ✳️ZEP 스크립트 상호작용 오브젝트 가이드
      • 📇오브젝트 npcProperty
  • ZEP SCRIPT API
    • 📘ZEP Script API
      • API Summary
      • ScriptApp
        • Lifecycle
        • Field
        • Storage
        • Event Listeners
        • Callbacks
        • Methods
      • ScriptMap
        • Field
        • Methods
      • ScriptPlayer
        • Field
        • Methods
      • ScriptWidget
        • Field
        • Event Listeners
        • Methods
      • UtilityClass
        • Time
Powered by GitBook
On this page

Was this helpful?

  1. ZEP Script 가이드
  2. 부록

오브젝트 npcProperty

PreviousZEP 스크립트 상호작용 오브젝트 가이드NextZEP Script API

Last updated 1 year ago

Was this helpful?

npcProperty는Map.putObjectWithKey(x, y, dynamicResource, option)함수의

option 파라미터에서 지정할 수 있으며, 다음 7가지 속성을 지정할 수 있습니다.

이름
타입
설명

name

string

오브젝트 위에 표시될 이름

hp

number

오브젝트의 현재 체력

hpMax

number

오브젝트의 최대 체력

gaugeWidth

number

체력 게이지바의 너비

생략시 이미지의 너비 크기로 설정됩니다.

hpColor

number

체력 게이지바의 색상 ex) 0x03ff03 (초록색)

예제 1 - npcProperty를 사용해 오브젝트 생성하기

let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
    left: [5, 6, 7, 8, 9],
    up: [15, 16, 17, 18, 19],
    down: [0, 1, 2, 3, 4],
    right: [10, 11, 12, 13, 14],
    dance: [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
    down_jump: [38],
    left_jump: [39],
    right_jump: [40],
    up_jump: [41],
}, 8);
App.addOnKeyDown(81, function (player) {
    const objectKey = "TestBlueMan";
    const bluemanObject = Map.putObjectWithKey(18, 6, blueman, {
	npcProperty: { name: "BlueMan", hpColor: 0x03ff03, hp: 100, hpMax: 100 },
	overlap: true,
	movespeed: 100,
	key: objectKey, 
	useDirAnim: true,
        offsetX: -8,
        offsetY: -32,
    });

    Map.playObjectAnimationWithKey(objectKey, "down", -1);
});

예제 2 - npcProperty로 체력이 깎이는 효과 구현하기

let blueman = App.loadSpritesheet('blueman.png', 48, 64, {
    left: [5, 6, 7, 8, 9], // 좌방향 이동 이미지
    up: [15, 16, 17, 18, 19],
    down: [0, 1, 2, 3, 4],
    right: [10, 11, 12, 13, 14],
    dance: [20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],
    down_jump: [38],
    left_jump: [39],
    right_jump: [40],
    up_jump: [41],
}, 8);

App.addOnKeyDown(81, function (player) {
    const objectKey = "TestBlueMan";
    const bluemanObject = Map.putObjectWithKey(18, 6, blueman, {
            npcProperty: { name: "BlueMan", hpColor: 0x03ff03, hp: 100, hpMax: 100 },
            overlap: true,
            collide: true, // ★ collid: true
            movespeed: 100, 
            key: objectKey, 
            useDirAnim: true,
            offsetX: -8,
            offsetY: -32,
    });

    Map.playObjectAnimationWithKey(objectKey, "down", -1);
});

App.onAppObjectAttacked.Add(function (p, x, y, layer, key) {
    const targetObject = Map.getObjectWithKey(key);
    targetObject.npcProperty.hp -= 10;
    if(targetObject.npcProperty.hp > 0) {
        const hpPercentage = targetObject.npcProperty.hp / targetObject.npcProperty.hpMax;
        if (hpPercentage < 0.3) {
            targetObject.npcProperty.hpColor = 0xff0000;
        } else if (hpPercentage < 0.7) {
            targetObject.npcProperty.hpColor = 0xffa500;
        }
        targetObject.sendUpdated();
    } else {
        Map.putObjectWithKey(targetObject.tileX, targetObject.tileY, null, { key: key })
    }
});

📇
29KB
npcProperty.zip
archive
예제 파일
29KB
npcProperty2.zip
archive
예제 파일