Recommended Posts

Hi guys, how are you doing?

 

I'm new in phaser and in game development with JS.

 

Anyone has implemented some kind of behaviors logic like flocking?
 

I tried to "Port" this example in processing.js into phaser, but i didn't have any luck.

 

http://processing.org/examples/flocking.html

 

 

Can someone show me some light and give some guidelines?

 

 

Thanks!

Share this post


Link to post
Share on other sites

Adding in your own boids system should be pretty straight forward. You'll have to find your own Vec2 implementation, but otherwise it shouldn't be too much effort. You'd just have to spawn a Sprite for each boid and update its position and rotation. I'd recommend doing it as a plugin, but you don't have to - could easily just be a State to start with.

Share this post


Link to post
Share on other sites

For rotation just use the sprite.rotation property (if the value is in radians, otherwise use sprite.angle).

 

For translation you modify the sprite.x and sprite.y coordinates directly.

This might have just saved me a whole load of time with some coding of exactly the same type of feature!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.