Anonymous avatar Anonymous committed 4a0cb29

use sprites for wall objects

Comments (0)

Files changed (1)

     }
 
     var createGroundSprite = function(x1,y1,x2,y2) {
-        console.log("sprite");
         var g = new createjs.Graphics();
         g.setStrokeStyle(2);
         g.beginStroke(createjs.Graphics.getRGB(100,100,100));
         display2d.stage.addChild( sprite );
     }
 
+    var createWallSprite = function(horizontal,vertical) {
+        var g = new createjs.Graphics();
+        g.setStrokeStyle(3);
+        g.beginStroke(createjs.Graphics.getRGB(100,100,100));
+        var h = (horizontal/2)*display2d.PTM;
+        var v = (vertical/2)*display2d.PTM;
+        g.moveTo(h,v);
+        g.lineTo(-h,-v);
+        console.log(horizontal,vertical,h,v,-h,-v);
+        var shape = new createjs.Shape(g);
+        shape.regX = 0;
+        shape.regY = 0;
+        return shape;
+    }
+
     var createWall = function(centerx, centery, horizontal, vertical, dontTouch) {
         bodies.createWall(world, centerx, centery, horizontal, vertical, dontTouch);
+        var sprite = createWallSprite(horizontal,vertical);
+        var viewCenter = display2d.viewCenterPixel();
+        sprite.x = centerx*display2d.PTM + viewCenter.x;
+        sprite.y = -centery*display2d.PTM + viewCenter.y;
+        display2d.stage.addChild( sprite );
     }
 
     var world = undefined;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.