this.ownerStage.mainContext.restore();
}
},
- //\83u\83\8d\83b\83N\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82ð\95Ï\8dX\82·\82é\82½\82ß\82É\82Í\82±\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82·\82é
- //\88ø\90\94\82É\82Í\81A\93\96\82½\82è\82ð\8am\82©\82ß\82é\97v\91f\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82Ì 1:\8d¶\8fã\8b÷ 2: \89E\89º\8b÷\82Ì\8dÀ\95W\82ð\8ew\92è
- //MovableStageObject.isCollided\82©\82ç\8cÄ\82Î\82ê\82é
- judgeCollideRange: function(x1, y1, x2, y2){
- return x2 >= this.origin.x && x1 < this.origin.x + this.size.x && y2 >= this.origin.y && y1 < this.origin.y + this.size.y;
- }
});
\ No newline at end of file
}.extend(BlockClass, {
judgeCollideRange: function(x1, y1, x2, y2){
- // 1 - - +
- // | |
- // | |
- // + - - 2
var retv = BlockClass.prototype.judgeCollideRange.apply(this, arguments);
if(retv){
if(this.phantomFlag || (y1 < this.origin.y)){
if((this.collideFlag & 8) != 0 && this.movingSpeed.y < 0) this.movingSpeed.y = 0; //\8fã\95û\8cü\82É\8fÕ\93Ë
},
- debugDraw: function(x, y){
- this.ownerStage.collisionMapContext.save();
- this.ownerStage.collisionMapContext.beginPath();
- this.ownerStage.collisionMapContext.strokeStyle='#00ff00';
- this.ownerStage.collisionMapContext.moveTo(x + this.collisionMarginLeft, y + this.collisionMarginTop);
- this.ownerStage.collisionMapContext.lineTo(x + this.collisionMarginLeft, y + this.size.y - this.collisionMarginBottom);
- this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.size.y - this.collisionMarginBottom);
- this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.collisionMarginTop);
- this.ownerStage.collisionMapContext.closePath();
- this.ownerStage.collisionMapContext.stroke();
- this.ownerStage.collisionMapContext.restore();
- },
moveTo : function(x, y) {
//\93\96\82½\82è\94»\92è\82Ì\8eÀ\91\95
return this.ownerStage.moveTo(this, x, y);
isCollided : function(obj, x, y)
{
//MovableStageObject\82ª(x, y)\82Ì\82Æ\82«\91\8a\8eè\82Ìobj\82Æ\8fÕ\93Ë\82·\82é\82©\94»\92è
- if(obj instanceof BlockClass || obj instanceof ItemClass)
- {
+ if(obj.judgeCollideRange){
return obj.judgeCollideRange(x + this.collisionMarginLeft, y + this.collisionMarginTop, x + this.size.x - this.collisionMarginRight, y + this.size.y - this.collisionMarginBottom);
}
return false;
// PCDSL\82È\82Ç\82©\82ç\97\98\97p\82Å\82«\82éID
this.id = "";
+
+ //\93\96\82½\82è\94»\92è\82Ì\83}\81[\83W\83\93\82Ì\8ew\92è
+ this.collisionMarginTop = 0;
+ this.collisionMarginLeft = 0;
+ this.collisionMarginRight = 0;
+ this.collisionMarginBottom = 0;
}
StageObject.prototype = {
className:"StageObject",
},
debugDraw: function(x, y){
//\8fÕ\93Ë\83}\83b\83v\82É\95`\89æ
- strokeRect(this.ownerStage.collisionMapContext, x, y, this.size.x, this.size.y);
+ this.ownerStage.collisionMapContext.save();
+ this.ownerStage.collisionMapContext.beginPath();
+ this.ownerStage.collisionMapContext.moveTo(x + this.collisionMarginLeft, y + this.collisionMarginTop);
+ this.ownerStage.collisionMapContext.lineTo(x + this.collisionMarginLeft, y + this.size.y - this.collisionMarginBottom);
+ this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.size.y - this.collisionMarginBottom);
+ this.ownerStage.collisionMapContext.lineTo(x + this.size.x - this.collisionMarginRight, y + this.collisionMarginTop);
+ this.ownerStage.collisionMapContext.closePath();
+ this.ownerStage.collisionMapContext.stroke();
+ this.ownerStage.collisionMapContext.restore();
},
- isCollided: function()
- {
- return false;
+ //\83u\83\8d\83b\83N\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82ð\95Ï\8dX\82·\82é\82½\82ß\82É\82Í\82±\82Ì\8aÖ\90\94\82ð\83I\81[\83o\81[\83\89\83C\83h\82·\82é
+ //\88ø\90\94\82É\82Í\81A\93\96\82½\82è\82ð\8am\82©\82ß\82é\97v\91f\82Ì\93\96\82½\82è\94»\92è\97Ì\88æ\82Ì 1:\8d¶\8fã\8b÷ 2: \89E\89º\8b÷\82Ì\8dÀ\95W\82ð\8ew\92è
+ //MovableStageObject.isCollided\82©\82ç\8cÄ\82Î\82ê\82é
+ // 1 - - +
+ // | |
+ // | |
+ // + - - 2
+ judgeCollideRange: function(x1, y1, x2, y2){
+ return !this.isPhantom &&
+ x2 >= this.origin.x + this.collisionMarginLeft &&
+ x1 <= this.origin.x + this.size.x - 1 - this.collisionMarginRight &&
+ y2 >= this.origin.y + this.collisionMarginTop &&
+ y1 <= this.origin.y + this.size.y - 1 - this.collisionMarginBottom;
},
bindAttribute: function(attr)
{
<body>
<div id="MainArea" style="width: 640px; height: 480px;"></div>
<div id="Resources"></div>
- <form>
- <textarea id="DebugText" rows="8" cols="64" style="z-index:4"></textarea>
- </form>
</body>
</html>
\ No newline at end of file