resource/animationclip
애니메이션 클립.
Animation clip.
AnimationClipextends Object
애니메이션 클립.
- 프레임은 스프라이트 시트 안의 영역(Rect) 목록이다. (Animator 가 그 영역을 스프라이트의 setImageRect 로 건다)
Animation clip.
- Frames are a list of areas (Rect) within the sprite sheet. (Animator applies that area with the sprite's setImageRect)
import { AnimationClip } from "./build/vanilla.js";
const atlasJson = {
frames: {
walk0: { frame: { x: 0, y: 0, w: 200, h: 200 } },
walk1: { frame: { x: 200, y: 0, w: 200, h: 200 } },
walk2: { frame: { x: 400, y: 0, w: 200, h: 200 } },
},
};
const clip = AnimationClip.fromAtlas(atlasJson, ["walk0", "walk1", "walk2"], 12, true);
const firstRect = clip.getFrame(0);
console.log(clip.getFrameCount(), clip.getDuration(), clip.isLoop(), firstRect.width);아틀라스 JSON 으로 클립 생성. (정적)
- TexturePacker 형식({ frames: { 이름: { frame: {x,y,w,h} } } })과 배열 형식([{x,y,w,h}, ...]) 둘 다 받는다.
- frameIds 순서대로 프레임을 뽑아 duration = frameCount / fps 로 만든다.
Creates a clip from atlas JSON. (static)
- Accepts both the TexturePacker format ({ frames: { name: { frame: {x,y,w,h} } } }) and the array format ([{x,y,w,h}, ...]).
- Picks frames in frameIds order and makes it with duration = frameCount / fps.
- atlasJsonobject
- 아틀라스 JSON. (TexturePacker 형식 객체나 영역 배열, 영역은 x, y 와 w, h 나 width, height)Atlas JSON. (a TexturePacker style object or a region array, each region has x, y and w, h or width, height)
- frameIdsstring[] | number[]
- 뽑을 프레임 이름이나 번호의 차례. (아틀라스에 없는 것은 건너뛴다)Order of frame names or indices to take. (entries missing from the atlas are skipped)
- fpsnumber
- 초당 프레임 수. (기본 10, 0 이하이면 지속 시간 0)Frames per second. (default 10, duration 0 if 0 or less)
- isLoopboolean
- 반복 재생 여부. (기본 참)Whether to loop. (default true)
반환ReturnsAnimationClip 만든 클립. (프레임은 Rect 목록)The created clip. (frames are a Rect list)
짝Counterpart: vanilla-engine AnimationClip.from_atlas
프레임 목록 설정.
Sets the frame list.
- framesRect[]
- 프레임 영역 목록. (스프라이트 시트 안의 픽셀 영역, fromAtlas 도 Rect 목록을 넣는다)Frame area list. (pixel areas within the sprite sheet, fromAtlas also puts in a Rect list)
짝Counterpart: vanilla-engine AnimationClip.set_frames
반복 재생 여부 설정.
Sets whether to loop.
- isLoopboolean
- 반복 재생하면 참.True to loop.
짝Counterpart: vanilla-engine AnimationClip.set_loop
애니메이션 지속 시간 설정.
Sets the animation duration.
- durationnumber
- 지속 시간. (초)Duration. (seconds)
짝Counterpart: vanilla-engine AnimationClip.set_duration
반복 재생 여부 반환.
Returns whether it loops.
반환Returnsboolean 반복 재생하면 참. (기본 거짓)True if it loops. (default false)
짝Counterpart: vanilla-engine AnimationClip.is_loop
대상 인덱스에 대한 프레임 반환.
Returns the frame for the target index.
- indexnumber
- 프레임 번호. (0 부터)Frame index. (from 0)
반환ReturnsRect 그 번호의 프레임 영역. (범위 밖이면 undefined)The frame area at that index. (undefined if out of range)
짝Counterpart: vanilla-engine AnimationClip.get_frame
프레임 목록 반환.
Returns the frame list.
반환ReturnsRect[] 프레임 영역 목록.Frame area list.
짝Counterpart: vanilla-engine AnimationClip.get_frames
전체 프레임 수 반환.
Returns the total frame count.
반환Returnsnumber 프레임 수.Frame count.
짝Counterpart: vanilla-engine AnimationClip.get_frame_count
애니메이션 지속 시간 반환.
Returns the animation duration.
반환Returnsnumber 지속 시간. (초, 기본 0)Duration. (seconds, default 0)
짝Counterpart: vanilla-engine AnimationClip.get_duration