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. Android:Resources don't contain package for resource number 0x7f050000

Hi,
I have included the drawable resource in the res package inside
drawable-hdpi and drawable-ldpi, but I am getting the warning
Resources don't contain package for resource number 0x7f050000
04 and the image drawable is nt getting drawn.
please help in resolving the issue.

Thanks in advance
PRoy

-- 

2. Going forever into /sys folder? Why?

Hi,

I have tested this behaviour on both a N1 and the emulator. Could
anyone tell me if that is a problem? I don't think it would go
forever. How can I avoid the recursive code going forever? What is
happening?

If you use any file browser/manager and starting going into /sys/
devices/w1 bus master/subsystem/devices/w1 bus master/subsystem it
will go inner forever, repeating that pattern [b]devices/w1 bus master/
subsystem/[/b] forever.

So when I run a recursive search it keeps going deeper and deeper and
seems never to finish.

What is happening, how to avoid this behaviour?

I tried different file manager and they all seems to be going forever
into these folders, although when I do a search through Astro it
doesn't seem to get stuck with this loop (It seems to ignore the /sys
folder, but I am not sure if this happens also in any other folder).

Regards.

-- 

3. error when open a facebook authentication url

4. Send Data To HTTPS Server From Android Application

5. Best Practice question: Passing an array to a View

6. several potential first activities - searching best practice advice

7. WebView + setHttpAuthUsernamePassword not working for me