0
\$\begingroup\$

I have a bullet that has projectile motion, this bullet is also an effect. Also the bullet has a shadow, that fade on specific time relatively to bullet. So I'm thinking of using the libgdx particle system (I am using an Entity Component-based System approach) so I created a particle component, or would you rather recommend to create another component for that specific effect? like a projectile component and linear component or a motion component in general.

Creating shadow, bullet, and other single object effect entity. Notice that I doesn't use any Box2d Physics yet.

Entity shadow = engine.createEntity();

... add texture, transform, movement or with gravity components

engine.addEntity(shadow);

To move the shadow entity

// Shadow
Vector2 linear = ...
movement.velocity.set(linear);

To move the bullet entity

// Bullet
gravity.vertical = 9.8f; // set earth gravity
Vector2 projectile = ...
movement.velocity.set(projectile);
// Also I need to calculate the time to reach its destination to add in lifespan

To create and move a ball entity

Entity ball = ...

// assume that the world has zero horizontal and 9.8 vertical Vector2 gravity 
// set the physics body and set restitution to have bounce
physics.body = createCircleBody(...); 

add(texture);
add(transform);
add(physics);

Every single object has lifespan so I added some lifespan component

LifespanComponent lifespan = ...
lifespan.duration = 0.5f; // let say half a second

Then the lifespan system will handle if the time reached the duration, then remove entity.

The problem is, Because Particle System has many moving objects, I don't know if I could use libgdx Particle System to create a single moving object that has a lifespan, like shadow, ball, bullet.

\$\endgroup\$
9
  • \$\begingroup\$ Can u give some examples for what you've done \$\endgroup\$ Commented Aug 27, 2016 at 9:47
  • \$\begingroup\$ @GioraGuttsait hey please check above, I updated and added some examples on how do I create and move entity \$\endgroup\$
    – ronscript
    Commented Aug 28, 2016 at 10:02
  • \$\begingroup\$ Can you please explain what do you mean in this bullet it also an effect? and what's exactly not working for you? \$\endgroup\$ Commented Aug 28, 2016 at 10:06
  • \$\begingroup\$ @GioraGuttsait it means, It doesn't have any physics body. \$\endgroup\$
    – ronscript
    Commented Aug 28, 2016 at 10:10
  • 1
    \$\begingroup\$ Okay, I get it. So what about what you're trying to do? I don't exactly understand your problem? \$\endgroup\$ Commented Aug 28, 2016 at 10:11

0

You must log in to answer this question.

Browse other questions tagged .