Retrieve position in an AnimationSet

by arnouf » Mon, 03 Nov 2008 02:11:24 GMT


Sponsored Links
 Hello,

I'm writting a small game but I've a BIG problem.
I've a picture where I set animation. The pic goes down and up on
screen. When I click on this pic I would like retrieve his position
but.

When I create the object, it's placed at 0,0...
When it goes down, if I click on it nothing happens. If I click on the
original position, I retrieve my position but it's still 0,0, even if
my pic is on the bottom of the screen!

Find below a part of my code
Animation rootSet = new AnimationSet(true);
                rootSet.setInterpolator(new AccelerateInterpolator());
                rootSet.setRepeatCount(Animation.INFINITE);
                rootSet.setRepeatMode(Animation.INFINITE);
                float positionYStart = 0;
                int timing = 0;

                while (positionYStart<maxHeight) {
                        // Create and add first child, a motion animation.
                                TranslateAnimation transRight = new 
TranslateAnimation(0,15, 0,
15);
                                transRight.setStartOffset(timing);
                                transRight.setFillAfter(true);
                                transRight.setDuration(speedUp);
                                rootSet.addAnimation(transRight);

                                TranslateAnimation transLeft = new 
TranslateAnimation(0,-15, 0,
15);
                                transLeft.setStartOffset(timing+speedUp);
                                transLeft.setDuration(speedUp);
                                transRight.setFillAfter(true);
                                rootSet.addAnimation(transLeft);

                                timing = timing+speedUp*2;
                                positionYStart = positionYStart+30;
                        }
                this.setAnimation(rootSet);
                this.startAnimation(rootSet);

This a class extended ImageView

public MyClass(Drawable d, Context c, int screenWidth){
                super(c);

                setImageDrawable(d);
                setBackgroundColor(Color.GRAY);
                super.setFrame(new Random().nextInt(screenWidth), 0, 30,30);
                setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
        }

Thanks for your help
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Can not decode high resolution picture

How to open a high resolution png picture, the picture is
4000x3000,but it crashed when it was decoded.

-- 

2. ROM kitchen

buat pengguna SGS dan Captivate ada tempat masak ROM online nih ..
bisa buat ROM seringan mungkin kalo mau :)

http://romkitchen.org/

-- 
--
Best Regards
Arianto C Nugroho
http://id.linkedin.com/in/ariantonugroho
YM-i : arianto.nugroho
skype-id : nugroho.arianto
(+254) 728 002 390
(+62) 817 9050 530

-- 
===============
"

3. Changing Media Player Proxy - RTSP

4. Testing classes of a project from another

5. external or usb mic for audio recording?

6. Programmatically Access Google Docs

7. SMS sending through HTC Desire