Jump to content

Gamma
 Share

Recommended Posts

In an example, using timers to spawn an object, the objects themselves drop to the bottom of the "world bound". How would I implement collision detection to the bottom of the world bound. In other words, how do I identify when the object touches the bottom of the world bound. My plan was to replicate this timer and remove the object when it touches the bottom of the world bound. How would I implement this. So far I've created a 'remove' function for when I figure this out.

 

Pseudo code of what I was trying to do is down below:

 

update function: 

this.game.physics.collide(objectGoesHere, [BOTTOM OF WORLD BOUND GOES HERE] , this.REMOVEFUNCTIONHERE, null, this);

What would go in the "Bottom of World Bound Goes Here" to make it so that the object when colliding with the bottom of the world bound, like in the link given above, executes and then I can call a function to remove it. 

 

Thank you in advance. 

Link to comment
Share on other sites

I'll try that after class. Also, there is another problem with physics. I took the same example (I put a link in the post above), and I put a group of platforms above the bottom of the screen. So when the objects fall they would hit the platform instead of the bottom of the screen. I'm not sure if this is a problem with Phaser or not, but I noticed when I specially implemented collision between the fall (repeated) objects and increased their velocity the slightest bit they would go past the platform and into the bottom of the screen. Why is that? Is it so fast that it cant collide with the platform?

 

Also, I cannot seem to spawn more than two timers that repeat falling objects to create a "double" falling object effect without one object hitting the platform and the other skipping the platform (Happens when I increase the velocity of the other object).

 

The game I made when implementing these methods is in the link below. You can see that I allowed the oranges to go out of bounds because of that "collision" and "physics" problem I've been having whenever I set the world Bounds for the oranges to " true" leaving me no choice but to make it false just to make the oranges hit the platform without any issues with velocity.

 

Robo Dash <-- The game with the problem

Link to comment
Share on other sites

Ignore the last post. I found my problem! I have multiple timers running at the same time and the objects flood through the screen. The solution is to stop the timers accordingly. Is there a way to 'check' if a timer (a repeating event timer)  is complete? 

 

var variableThatHoldsTimingEvent = this.game.timer.events.repeat(.....)

 

update function:

 

if(variableThatHold... is complete)

{

//start other timer that repeats another set of objects

}

 

 

I've been having trouble implementing the 'onComplete' property for timers. 

Link to comment
Share on other sites

  • 1 month later...

In an example, using timers to spawn an object, the objects themselves drop to the bottom of the "world bound". How would I implement collision detection to the bottom of the world bound. In other words, how do I identify when the object touches the bottom of the world bound. My plan was to replicate this timer and remove the object when it touches the bottom of the world bound. How would I implement this. So far I've created a 'remove' function for when I figure this out.

 

Pseudo code of what I was trying to do is down below:

 

update function: 

this.game.physics.collide(objectGoesHere, [BOTTOM OF WORLD BOUND GOES HERE] , this.REMOVEFUNCTIONHERE, null, this);

What would go in the "Bottom of World Bound Goes Here" to make it so that the object when colliding with the bottom of the world bound, like in the link given above, executes and then I can call a function to remove it. 

 

Thank you in advance. 

 

I want to know the exact same thing, checking for whether or not the object is at certain positions near the edge doesn't seem very reliable to me. I want to know what the best way to do it is for any and all world bounds, so that I can call functions exactly when something collides with them.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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