मैंने जावा में एक सामान्य टिव इंजन बनाया है जिसका उपयोग आप अपने sprites सहित कुछ भी एनिमेट करने के लिए कर सकते हैं। यह एंड्रॉइड और गेम्स के लिए अनुकूलित है क्योंकि यह कचरा संग्रह से बचने के लिए रनटाइम पर कुछ भी आवंटित नहीं करता है। इसके अलावा, ट्वीन्स पूल किए जाते हैं, वास्तव में: कोई कचरा संग्रह बिल्कुल नहीं!
आप एक एंड्रॉइड एप्लिकेशन के रूप में एक पूर्ण डेमो here देख सकते हैं, या here वेबग्ल HTML पृष्ठ (क्रोम की आवश्यकता है) के रूप में देख सकते हैं!
आपको बस अपने सभी sprites को टिवन समर्थन जोड़ने के लिए TweenAccessor
इंटरफ़ेस को लागू करना है। आपको अपनी स्प्राइट क्लास को भी बदलना नहीं है, बस SpriteTweenAccessor
कक्षा बनाएं जो TweenAccessor<Sprite>
लागू करती है, और इसे प्रारंभ में इंजन पर पंजीकृत करें। बस GetStarted wiki page पर एक नजर है;)
http://code.google.com/p/java-universal-tween-engine/
मैं भी एक दृश्य समयावधि संपादक है कि किसी भी आवेदन में एम्बेड किया जा सकता का निर्माण कर रहा हूँ। इसमें फ्लैश संलेखन उपकरण और अभिव्यक्ति मिश्रण (एक सिल्वरलाइट देव उपकरण) के समान समयरेखा होगी।
पूरे इंजन को अत्यधिक दस्तावेज किया गया है (सभी सार्वजनिक तरीकों और कक्षाओं में विस्तृत जावाडोक है), और सिंटैक्स ग्रीसॉक के टिनमैक्स/ट्विनलाइट इंजन के समान है जो फ़्लैश दुनिया में उपयोग किया जाता है। ध्यान दें कि यह हर रॉबर्ट पेननर आसान समीकरण का समर्थन करता है।
// Arguments are (1) the target, (2) the type of interpolation,
// and (3) the duration in seconds. Additional methods specify
// the target values, and the easing function.
Tween.to(mySprite, Type.POSITION_XY, 1.0f).target(50, 50).ease(Elastic.INOUT);
// Possibilities are:
Tween.to(...); // interpolates from the current values to the targets
Tween.from(...); // interpolates from the given values to the current ones
Tween.set(...); // apply the target values without animation (useful with a delay)
Tween.call(...); // calls a method (useful with a delay)
// Current options are:
yourTween.delay(0.5f);
yourTween.repeat(2, 0.5f);
yourTween.repeatYoyo(2, 0.5f);
yourTween.pause();
yourTween.resume();
yourTween.setCallback(callback);
yourTween.setCallbackTriggers(flags);
yourTween.setUserData(obj);
// You can of course chain everything:
Tween.to(...).delay(1.0f).repeat(2, 0.5f).start();
// Moreover, slow-motion, fast-motion and reverse play is easy,
// you just need to change the speed of the update:
yourTween.update(delta * speed);
बेशक
, कोई ट्वीन इंजन एक तरीका प्रदान शक्तिशाली दृश्यों :)
Timeline.createSequence()
// First, set all objects to their initial positions
.push(Tween.set(...))
.push(Tween.set(...))
.push(Tween.set(...))
// Wait 1s
.pushPause(1.0f)
// Move the objects around, one after the other
.push(Tween.to(...))
.push(Tween.to(...))
.push(Tween.to(...))
// Then, move the objects around at the same time
.beginParallel()
.push(Tween.to(...))
.push(Tween.to(...))
.push(Tween.to(...))
.end()
// And repeat the whole sequence 2 times
// with a 0.5s pause between each iteration
.repeatYoyo(2, 0.5f)
// Let's go!
.start();
मुझे आशा है कि आप आश्वस्त कर रहे हैं का निर्माण करने के बिना पूर्ण नहीं हो :) वहाँ बहुत से लोगों को पहले से ही प्रयोग कर रहे हैं अपने खेल में इंजन या एंड्रॉइड यूआई एनीमेशन के लिए।
वाह देखें, यह बहुत अच्छा है, धन्यवाद। –
मैंने अभी थोड़ा सा विवरण अपडेट किया है, क्योंकि इंजन ने पहली बार जवाब लिखा था क्योंकि इंजन ने बड़ी प्रगति की है :) –
@ AurélienRibon, क्या यह एक स्प्राइट से एक अलग स्प्राइट में एनीमेशन प्रदान करता है? –