stereoa Posted January 3, 2017 Share Posted January 3, 2017 Hello all. I am working on a 2d top down game. I am trying to do some level generation in a state before the main game state. I call arcade.physics.overlap/collide and it never returns true even though if you check out my game it does indeed happen. Here's my game: http://thehibberts.us/hellherd/ The little white squares should not spawn on top of the big black ones. Here's a snippet of code to show what I can't implement: var worldCenter = new Point(this.game.world.centerX, this.game.world.centerY); for (i = 0; i < STARTING_CATTLE_COUNT; i++) { var cow = new Cow(this.game, worldCenter.x + Tools.randomNum(-75, 75), worldCenter.y + Tools.randomNum(-75, 75)); this.game.cattle.add(cow); if(this.game.physics.arcade.overlap(cow, this.game.pits)) { //todo: this never gets hit } } Link to comment Share on other sites More sharing options...
stereoa Posted January 6, 2017 Author Share Posted January 6, 2017 I fixed my problem. I was initializing these sprites with no width or height before enabling their physics. Their bodies' width and height resulted in 1, which caused the overlap function to fail. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts