this.image0 = img;
//画像はなし
this.image = null;
- this.phantomFlag = false;
+ this.phantomFlag = 0;
+ this.debugMode = true;
}.extend(BlockClass, {
- judgeCollideRange: function(x1, y1, x2, y2){
+ judgeCollideRange: function(x1, y1, x2, y2, obj){
+ //objは範囲の対象となるオブジェクトのインスタンス。省略可能
+ // 1 - - +
+ // | |
+ // | |
+ // + - - 2
var retv = BlockClass.prototype.judgeCollideRange.apply(this, arguments);
if(retv){
- if(this.phantomFlag || (y1 < this.origin.y)){
+ var cd = this.judgeCollideRange_getDirection(x1, y1, x2, y2);
+ if(this.phantomFlag || (cd & CollideTop)){
//上から当たった場合はなかったことにする
retv = false;
- this.phantomFlag = true;
- } else{
+ this.phantomFlag = 2;
+ } else if(obj == this.ownerStage.userControlledCharacter && (obj.origin.y >= this.origin.y + this.size.y - 1)){
//下から当たっていたら画像を表示させて、さらにこの関数をベースクラスのものに戻す。
this.image = this.image0;
this.judgeCollideRange = BlockClass.prototype.judgeCollideRange;
this.debugDraw = BlockClass.prototype.debugDraw;
+ } else{
+ retv = false;
}
} else{
- this.phantomFlag = false;
+ if(obj == this.ownerStage.userControlledCharacter){
+ if(this.phantomFlag > 0){
+ this.phantomFlag--;
+ }
+ }
}
return retv;
},