Ninjadoodle Posted March 20, 2018 Share Posted March 20, 2018 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 Quote Link to comment Share on other sites More sharing options...
enpu Posted March 21, 2018 Share Posted March 21, 2018 @Ninjadoodle 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: https://www.panda2.io/examples#misc-example1 Ninjadoodle 1 Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted March 21, 2018 Author Share Posted March 21, 2018 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 Quote Link to comment Share on other sites More sharing options...
enpu Posted March 21, 2018 Share Posted March 21, 2018 @Ninjadoodle 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.