Jump to content

Overlap or Collide not working reliably


stereoa
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...