Class: ResourceManager
리소스를 비동기로 로드하는 역할을 맡는다. 모든 리소스가 불러와졌다면 등록된 콜백 함수를 호출한다.
Description
Usage
new ResourceManager()
Members
(static) loadedResourceCount
불러온 리소스의 개수
Properties:
Type | Description |
---|---|
number |
(static) totalResourceCount
불러와야할 리소스의 총 개수
Properties:
Type | Description |
---|---|
number |
(static) allResourceLoadedCallback
모든 리소스가 불러와졌을 때 실행할 콜백함수
Properties:
Type | Description |
---|---|
function |
Methods
(static) loadResource(path, constructor, callbackopt) → {HTMLAudioElement, HTMLImageElement}
path를 경로로 하는 리소스를 생성한다. 이 때 리소스는 constructor에 의해 생성된다.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
path
|
string |
리소스의 경로 |
|
constructor
|
Audio.constructor|Image.constructor |
리소스를 생성할 생성자 |
|
callbackopt
|
function | () => {} |
리소스가 생성된 이후에 실행할 콜백함수 |
Returns:
(static) onResourceLoad(count)
로드한 리소스의 개수를 count만큼 증가시킨다.
Parameters:
Name | Type | Description |
---|---|---|
count
|
number |
로드한 리소스의 개수 |
(static) isAllResourceLoaded() → {boolean}
모든 리소스가 로드되었는지를 확인한다.
Returns:
(static) removeResourceLoadedCallback()
모든 리소스가 로드되었을 때 실행될 콜백함수를 초기화한다.
(static) addResourceCount(count)
로드할 리소스의 총 개수를 증가시킨다.
Parameters:
Name | Type | Description |
---|---|---|
count
|
number |
로드할 리소스의 개수 |
(static) setAllResourceLoadedCallback(callback)
모든 리소스가 로드되었을 때 실행할 콜백함수를 설정한다.
Parameters:
Name | Type | Description |
---|---|---|
callback
|
function |
(static) getTotalResourceCount() → {number}
로드해야할 리소스의 총 개수를 반환한다.
Returns:
(static) getLoadedResourceCount() → {number}
로드한 리소스의 개수를 반환한다.