OSDN Git Service

キャラが必ず最前面に表示されるようにした。
authorttwilb <ttwilb@users.sourceforge.jp>
Tue, 3 Sep 2013 15:13:21 +0000 (00:13 +0900)
committerttwilb <ttwilb@users.sourceforge.jp>
Tue, 3 Sep 2013 15:13:21 +0000 (00:13 +0900)
またstageObjectのforceTopMost = trueで必ずそのオブジェクトはキャラよりも最前面に表示されるようにした。

www/corelib/classes/GameStageClass.js
www/corelib/classes/StageObjectClass.js

index c4b6e6e..32437e0 100644 (file)
@@ -152,6 +152,24 @@ GameStage.prototype = {
                }
        },
        drawAsPoint: function(x, y){
+       
+               // \95\\8e¦\82Ì\8fd\82Ë\8d\87\82í\82¹\8f\87 : \91¼\82Ì\8d\80\96Ú < \83L\83\83\83\89 < forceTopMost==true\82Ì\8d\80\96Ú
+       
+               var characterList = [];
+               var topList = [];
+               var drawItem = function(stgobj)
+               {
+                       var px = stgobj.origin.x - x, py = stgobj.origin.y - y;
+                       
+                       if(px > -stgobj.size.x && py > -stgobj.size.y && px < 640 && py < 480)
+                       {
+                               stgobj.draw(px, py);
+                               if(this.debugMode){
+                                       stgobj.debugDraw(px, py);
+                               }
+                       }
+               };
+               
                //\82·\82×\82Ä\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dÄ\95`\89æ
                //x, y\82Í\95`\89æ\88Ê\92u\82Ì\83I\83t\83Z\83b\83g
                for(var sp in this.stageObjectList)
@@ -159,17 +177,30 @@ GameStage.prototype = {
                        //\8ae\8eíStageObject\82Ìdraw\82ð\8eÀ\8ds
                        for(var i = 0, li = this.stageObjectList[sp].length; i < li; i++){
                                var stgobj = this.stageObjectList[sp][i];
-                               var px = stgobj.origin.x - x, py = stgobj.origin.y - y;
-                               
-                               if(px > -stgobj.size.x && py > -stgobj.size.y && px < 640 && py < 480)
+                               if(stgobj.forceTopMost)
                                {
-                                       stgobj.draw(px, py);
-                                       if(this.debugMode){
-                                               stgobj.debugDraw(px, py);
-                                       }
+                                       topList.push(stgobj);
+                               }else if(stgobj instanceof CharacterClass)
+                               {
+                                       characterList.push(stgobj);
+                               }else
+                               {
+                                       drawItem(stgobj);
                                }
                        }
                }
+               
+               for(var i in characterList)
+               {
+                       var stgobj = characterList[i];
+                       drawItem(stgobj);
+               }
+               
+               for(var i in topList)
+               {
+                       var stgobj = topList[i];
+                       drawItem(stgobj);
+               }
        },
        drawBackground: function(){
                if(this.background)
index 991f241..1f4419e 100644 (file)
@@ -26,6 +26,8 @@ function StageObject(ownerStage, args){
        //\82»\82ê\88È\8aO\82Ì\8fê\8d\87\82Í\94C\88Ó\82Ì\83^\83C\83~\83\93\83O\82ÅchecktouchingDirection\82ð\8cÄ\82Ñ\8fo\82·\82×\82µ\81B
        this.touchingDirection = 0;
        this.collidedObjects = new Array();
+       
+       this.forceTopMost = false;
 }
 StageObject.prototype = {
        className:"StageObject",