# A Physics / HiTest Question

## Recommended Posts

Hi @enpu

1 - What would be the best way to tween / animate a lazer at a particular angle in Panda.

I don't really want to use physics if I don't have to - but do you think that would be the easiest option?

Basically I don't want any gravity, just a projectile moving in a direction.

2 -  Since I want to avoid using Physics - I know you've added a HitTest method.

This method will only test two bounding boxes, is that right?

Any way a circle collision could be added to panda?

Thanks heaps

##### Share on other sites

1) This has really nothing to do with physics. Physics is for stuff like gravity, friction, collision etc. What you are looking for is just to move sprite based on speed and angle, which is basic trigonometry:

``````sprite.position.x += speed * Math.cos(angle);
sprite.position.y += speed * Math.sin(angle);``````

2) To detect if two circles are overlapping, calculate the distance between them. If it's lower than the radius of the two circles combined, then they are overlapping:

``````var distance = a.position.distance(b.position);
if (distance < aRadius + bRadius) {
// Circles overlapping
}``````

Here is live example for both:

##### Share on other sites

Hi @enpu

Thanks heaps for the examples, they are really useful.

I've kinda been confused on whether I should be using basic physics for stuff like this, but this makes complete sense.

I've only made stuff like this in Construct, which has behaviors like Custom Movement - which lets you send an object in a specific direction.

Thank you for pointing me in the right direction

##### Share on other sites

No problem!

That's the thing i don't like in Construct, you don't learn the technics on how stuff really works. But then it is targeted to non-technical users.

## 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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.