new collie.Sensor(htOption)
A Simple 1:N Collision Detection
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
htOption |
Object |
|
Example
var sensor = new collie.Sensor({
frequency : 10
});
// Add target objects
sensor.add(oDisplayObjectTarget, "anyText");
sensor.add(oDisplayObjectTarget, "anyText");
sensor.add(oDisplayObjectTarget, "anyText");
sensor.add(oDisplayObjectTarget, "otherText");
sensor.add(oDisplayObjectTarget, "otherText");
sensor.add(oDisplayObjectTarget, "otherText");
// Add target object that has a circle shape
sensor.add(oDisplayObjectTarget, "otherText", 15); // radius
// Add target object that has a margin of width and a margin of height
sensor.add(oDisplayObjectTarget, "otherText", 10, 20); // a margin of width, a margin of height
// Add a listener object for detecting target objects set a category as "anyCategory"
sensor.addListener(oDisplayObjectListener, "anyText", function (a, b) {
// begin collision
}, function (a, b) {
// end collision
});
// Add a listener object that has a circle shape
sensor.addListener(oDisplayObjectListener, "anyText", function (a, b) {
// begin collision
}, function (a, b) {
// end collision
}, 15); // radius
// start sensing
sensor.start();
// stop sensing
sensor.stop();
Extends
Requires
- module:collie.addon.js
Members
-
RAY_SENSING_DISTANCENumber
-
If you want to make sensitive higher a case of pass through like a bullet, you should decrease this value. (px) It will affect the performance
Methods
-
add(oDisplayObject, sCategory, vWidth, nHeight)
-
충돌 감지에 객체 등록
Name Type Description oDisplayObjectcollie.DisplayObject sCategoryString 여러 개의 카테고리 입력 가능, 구분은 콤마(,)
vWidthNumber 이 값만 있으면 radius, 원형으로 탐지하고,
nHeightNumber vWidth와 같이 이 값도 있으면 중심으로 부터의 사각형으로 탐지한다.
-
addListener(oDisplayObject, sCategory, fBeginCallback, fEndCallback, vWidth, nHeight)
-
충돌감지 보고를 받을 객체를 등록
Name Type Description oDisplayObjectcollie.DisplayObject 등록된 객체들과 충돌 감지할 객체
sCategoryString 여러 개의 카테고리 입력 가능, 구분은 콤마(,)
fBeginCallbackFunction 충돌이 일어났을 때 실행될 함수
Name Type Description listenercollie.DisplayObject 리스너 객체
triggercollie.DisplayObject 충돌이 일어난 객체
fEndCallbackFunction 충돌이 끝났을 때 실행될 함수
Name Type Description listenercollie.DisplayObject 리스너 객체
triggercollie.DisplayObject 충돌이 일어난 객체
vWidthNumber 이 값만 있으면 radius, 원형으로 탐지하고,
nHeightNumber vWidth와 같이 이 값도 있으면 중심으로 부터의 사각형으로 탐지한다.
-
inherited attach(vEvent, fHandler){collie.Component}
-
이벤트 핸들러 추가
Name Type Description vEventObject | String fHandlerFunction Returns:
체이닝 지원
-
inherited detach(vEvent, fHandler)
-
이벤트 핸들러를 해제한다
Name Type Description vEventObject | String fHandlerFunction 값이 없을 경우 이 이벤트에 할당된 전체 핸들러를 해제한다
-
inherited detachAll(sName)
-
모든 이벤트 핸들러를 해제
Name Type Description sNameString 이벤트 이름, 값이 없으면 이 컴포넌트에 할당된 모든 이벤트를 해제한다
-
detect(oDisplayObject, sCategory, htBoundaryListener, fBeginCallback, fEndCallback)
-
충돌 갑지 체크
Name Type Description oDisplayObjectcollie.DisplayObject 등록된 객체들과 충돌 감지할 객체
sCategoryString 여러 개의 카테고리 입력 가능, 구분은 콤마(,)
htBoundaryListenerObject Listener의 Boundary는 미리 구해 놓는다
fBeginCallbackFunction 충돌이 일어났을 때 실행될 함수
fEndCallbackFunction 충돌이 끝났을 때 실행될 함수
-
inherited fireEvent(sName, oEvent){Boolean}
-
이벤트 발생
Name Type Description sNameString oEventObject Returns:
발생 중 collie.ComponentEvent의 stop 메소드가 실행될 경우 false를 반환한다
-
inherited get(sName){Variables}
-
DisplayObject와 Layer의 서로 다른 인터페이스를 맞추기 위한 임시 메서드
Name Type Description sNameString -
inherited option(vName, vValue, bNotOverwrite)
-
컴포넌트의 옵션을 설정한다.
Name Type Description vNameObject | String 옵션 이름이나 여러 옵션을 설정할 수 있는 객체를 넣을 수 있다.
vValueVariables optional 옵션 값, 값이 없다면 해당 옵션 값을 반환한다.
bNotOverwriteBoolean optional 이 값이 true면 기존에 값이 있을 경우 덮이 씌우지 않는다
Example
component.option({ a : 1, b : true });
component.option("a", 1); component.option("a"); // return 1
-
inherited optionSetter(sName, fSetter)
-
옵션 값이 설정될 때 실행될 함수를 지정한다. Setter는 한 속성 당 한 개의 함수만 설정할 수 있다.
Name Type Description sNameString fSetterFunction -
remove(oDisplayObject, sCategory)
-
충돌 감지에서 제거
Name Type Description oDisplayObjectcollie.DisplayObject sCategoryString 여러 개의 카테고리 입력 가능, 구분은 콤마(,), 값이 없을 시에는 모든 카테고리에서 제거
-
inherited set(sName, vValue, bNotOverwrite){Object}
-
DisplayObject와 Layer의 서로 다른 인터페이스를 맞추기 위한 임시 메서드
Name Type Description sNameString vValueVariables bNotOverwriteBoolean optional Returns:
method chaining
-
start()
-
감지 시작
-
stop()
-
감지 끝
-
inherited unset(sKey)
-
옵션을 제거한다
Name Type Description sKeyString