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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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