OSDN Git Service

当たり判定の修正と敵キャラクターを踏んでダメージを与える動作の実装
[h58pcdgame/GameScriptCoreLibrary.git] / www / corelib / classes / HiddenBlockClass.js
index 86703a5..f404685 100644 (file)
@@ -7,24 +7,37 @@ var HiddenBlockClass = function(ownerStage, args)
        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;
        },