2012-03-14 14 views
5

मेरे खेल में मैं उपयोगLibGDX: कण पैमाने

static final float FRUSTUM_WIDTH = 10; 
static final float FRUSTUM_HEIGHT = 15; 

तो जब मैं कणों आकर्षित वे पूरे स्क्रीन लेने के लिए और विशाल कर रहे हैं! तो मैं अपनी जरूरतों को पूरा करने के लिए उन्हें कैसे स्केल कर सकता हूं?

// बेंच लैब्स

उत्तर

5

या तो आप कण संपादक का उपयोग (ईमानदार मुझे नहीं लगता कि होने के लिए कणों का आकार बदलने के लिए यह एक अच्छा विचार है, जैसा कि आपने बताया है कि कण बहुत छोटे नहीं होंगे (किसी और चीज के लिए मैं वास्तव में इसकी अनुशंसा करता हूं)) या आप कण प्रभाव फ़ाइल खोलें। इसे संपादक द्वारा उत्पन्न किया जाना चाहिए या आप इसे उदाहरणों से कॉपी कर सकते हैं।

- Scale - 
lowMin: 0.0 
lowMax: 0.0 
highMin: 0.6 
highMax: 0.6 
relative: false 
scalingCount: 1 
scaling0: 1.0 
timelineCount: 1 
timeline0: 0.0 

highMin और highMax समायोजित के रूप में की जरूरत: इस फ़ाइल में नीचे दिए गए फ़ील्ड खोज करते हैं।

+0

यह और अन्य सभी नवीनतम लाइब्रेरी के साथ काम नहीं कर रहे हैं, कोई मदद? – lacas

+0

व्यक्तिगत रूप से, मैंने थोड़ी देर में libgdx का उपयोग नहीं किया है, क्षमा करें :( – dom

2

ठीक है, आप कण संपादक का उपयोग और वहाँ आकार को समायोजित कर सकते हैं:

http://www.badlogicgames.com/wordpress/?p=1255

+0

ये धन्यवाद। लेकिन यह किसी भी 2017 अपडेट से 1 –

+0

से कम नहीं जाता है? – lacas

25
ParticleEffect pe = new ParticleEffect(); 
    pe.load(Gdx.files.internal("data/particle/particle.p"), Gdx.files.internal("data/particle")); 
    pe.setPosition(x, y); 

    float pScale = 0.2f; 

    float scaling = pe.getEmitters().get(0).getScale().getHighMax(); 
    pe.getEmitters().get(0).getScale().setHigh(scaling * pScale); 

    scaling = pe.getEmitters().get(0).getScale().getLowMax(); 
    pe.getEmitters().get(0).getScale().setLow(scaling * pScale); 

    scaling = pe.getEmitters().get(0).getVelocity().getHighMax(); 
    pe.getEmitters().get(0).getVelocity().setHigh(scaling * pScale); 

    scaling = pe.getEmitters().get(0).getVelocity().getLowMax(); 
    pe.getEmitters().get(0).getVelocity().setLow(scaling * pScale); 
+1

यह वास्तव में सहायक है, धन्यवाद! –

2

मैं विक्टर के रूप में ही दृष्टिकोण का इस्तेमाल किया है, लेकिन क्या मेरे लिए काम किया:

ParticleEffect effect = new ParticleEffect(); 
    effect.load(Gdx.files.internal("particle/version1.p"), Gdx.files.internal("particle")); 
    effect.setPosition(x, .y); 
    float pScale = 0.02f; 
    float scaling; 
    Array<ParticleEmitter> emitters = effect.getEmitters(); 
    for (ParticleEmitter e : emitters) { 

     scaling = e.getScale().getHighMax(); 
     e.getScale().setHigh(scaling * pScale); 

     scaling = e.getScale().getLowMax(); 
     e.getScale().setLow(scaling * pScale); 

     scaling = e.getVelocity().getHighMax(); 
     e.getVelocity().setHigh(scaling * pScale); 

     scaling = e.getVelocity().getLowMax(); 
     e.getVelocity().setLow(scaling * pScale); 

     scaling = e.getSpawnHeight().getHighMax(); 
     e.getSpawnHeight().setHighMax(scaling * pScale); 

     scaling = e.getSpawnHeight().getLowMax(); 
     e.getSpawnHeight().setLowMax(scaling * pScale); 

     scaling = e.getSpawnHeight().getHighMin(); 
     e.getSpawnHeight().setHighMin(scaling * pScale); 

     scaling = e.getSpawnHeight().getLowMin(); 
     e.getSpawnHeight().setLowMin(scaling * pScale); 

     scaling = e.getSpawnWidth().getHighMax(); 
     e.getSpawnWidth().setHighMax(scaling * pScale); 

     scaling = e.getSpawnWidth().getLowMax(); 
     e.getSpawnWidth().setLowMax(scaling * pScale); 

     scaling = e.getSpawnWidth().getHighMin(); 
     e.getSpawnWidth().setHighMin(scaling * pScale); 

     scaling = e.getSpawnWidth().getLowMin(); 
     e.getSpawnWidth().setLowMin(scaling * pScale); 

     scaling = e.getXOffsetValue().getLowMax(); 
     e.getXOffsetValue().setLowMax(scaling * pScale); 

     scaling = e.getXOffsetValue().getLowMin(); 
     e.getXOffsetValue().setLowMin(scaling * pScale); 

     scaling = e.getYOffsetValue().getLowMax(); 
     e.getYOffsetValue().setLowMax(scaling * pScale); 

     scaling = e.getYOffsetValue().getLowMin(); 
     e.getYOffsetValue().setLowMin(scaling * pScale); 
    } 
    effect.start();