Basically my problem is simple - I have a ParticleEffect which looks nice on small screen but on my private phone (Samsung S4) it looks very small. My question is: How can I scale the effect?
I have already done something like this:
// Callback method
public void addEffect(Vector2 position, boolean special) {
// Callback Method for the particle effects
PooledEffect effect;
if (!special)
effect = (MathUtils.random(0, 1) == 0) ? yellow_star_pool.obtain()
: green_star_pool.obtain();
else
effect = special_star_pool.obtain();
effect.setPosition(position.x, position.y);
effect.scaleEffect(Values.Scalar_Width*1.3f);
effects.add(effect);
}
But the result is that the effect is scaling exponentially, something I don't want.
I just want the effect to be scaled so that it will look the same on all screens. How can I achieve that?
First, I want to explain why current approach doesn't work. Note that the method you use for scaling is named
scaleEffect
, notsetScale
. Every time you call it the effect will be scaled relative to its current state. When you use pooled particle effects you scale the effect as many times as the particle had been reused. That's why you see it scaling exponentially.So, the solution is to scale only the particle effect that you use as a prototype for the pool. Something like:
Then you didn't have to scale every particle effect you obtain.