좋아, 그래서 나는 더 아직 플래시 또는 EaselJS이에 대한 기능 내장이없는 것 같아요, 그래서 나는이 함께했다 그것은 확인을 작동합니다. 그러나 모양의 실제 보이는 픽셀이 아닌 사각형 MovieClip 경계인 hitBox 만 검사합니다. HTML5 캔버스 용 Flash에서는 동영상 클립 인스턴스의 너비 및 높이가 지원되지 않으므로 속성 패널에서 해당 장면을 살펴 봐야합니다. 뿐만 아니라 (shapeA 그러나 hitTest (shapeB가)) {추적이 경우`좌표
var objA = this.bullet ; // The selected MovieClip
var objA_width = 20; // enter selected Movieclip's width (you can't find out with script, duh!)
var objA_height = 10; // enter selected Movieclip's height
var objB = this.target; // The MovieClip to test collision with
var objB_width = 100; // enter it's width
var objB_height = 100; // ...and it's height
this.addEventListener("tick",hitTest.bind(this));
function hitTest(){
if (collision(objA, objB, objA_width,objA_height,objB_width,objB_height)){
// code to run on collision;
}
}
var mca = new Object();
var mcb = new Object();
function collision(a,b,aWidth,aHeight,bWidth,bHeight) {
mca.xr = a.x + (aWidth/2); //the right edge of movieclip A
mca.xl = a.x - (aWidth/2); //the left edge of movieclip A
mca.yt = a.y - (aHeight/2); //the top edge of movieclip A
mca.yb = a.y + (aHeight/2); //the bottom edge of movieclip A
mcb.xr = b.x + (bWidth/2);
mcb.xl = b.x - (bWidth/2);
mcb.yt = b.y - (bHeight/2);
mcb.yb = b.y + (bHeight/2);
xHit = mca.xr > mcb.xl && mca.xl < mcb.xr; // returns true if the is any horisontal overlappnig
yHit = mca.yt < mcb.yb && mca.yb > mcb.yt; // returns true if the is any vertical overlapping
if (xHit && yHit){return true;}
}
실제 물체에 그러나 hitTest 시도 "A 히트가 있었다 ..!"; 어쨌든, 여기에 내가 생각 해낸거야 }' –
Shucks는 HTML5에 대한 것임을 깨달았습니다. 나는 그럴 수 있는지 아닌지 잘 모릅니다. 그러나 특정 플래시 기능이 HTML5 변환에 없으면 놀랄 일이 아닙니다. –
이 기능은 게임 개발에있어 보편적 인 기능이라고 생각합니다. –