Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7036745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:27:39+00:00 2026-05-28T01:27:39+00:00

I have code like this: public class SnowFallService extends BaseLiveWallpaperService implements IOnAreaTouchListener{ // ===========================================================

  • 0

I have code like this:

public class SnowFallService extends BaseLiveWallpaperService implements IOnAreaTouchListener{

    // ===========================================================
    // Constants
    // ===========================================================

    private static final int CAMERA_WIDTH = 480;
    private static final int CAMERA_HEIGHT = 800;

    private ArrayList<Sprite> allSnow = new ArrayList<Sprite>();
    // ===========================================================
    // Fields
    // ===========================================================

    private ScreenOrientation screenOrientation;

    private static TextureRegion snowTexture;
    private static TextureRegion backgroundTexture;
    private static Textures texture = null;

    private Scene mScene;

    public org.anddev.andengine.engine.Engine onLoadEngine() {
        return new org.anddev.andengine.engine.Engine(new EngineOptions(true, this.screenOrientation, new FillResolutionPolicy(), new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT)));
    }

    public void onLoadResources() {
        texture = new Textures(this, getEngine());
    }

    public void onUnloadResources() {

    }

    public Scene onLoadScene() {

        final Scene mScene = new Scene();
        backgroundTexture = texture.getBackground();
        mScene.attachChild(new Sprite(0, 0, backgroundTexture));
        snowTexture = texture.getSnowTextureRegion();

        mScene.registerUpdateHandler(new IUpdateHandler() {
            private long lastRaindropAdd = 0;

            @Override
            public void onUpdate(final float pSecondsElapsed) {
                int size = allSnow.size();
                int tmpInt = 0;
                Random randGen = new Random();
                for (int i = 0; i < size; i++) {
                    if (allSnow.get(i) != null){
                        Sprite snow = allSnow.get(i);

                        tmpInt = randGen.nextInt(4);
                        snow.setPosition(snow.getX() + (randGen.nextInt(5) - randGen.nextInt(5)) * randGen.nextInt(3), snow.getY() + tmpInt);

                        if (snow.getY() > CAMERA_HEIGHT || snow.getX() > CAMERA_WIDTH) {
                            synchronized(snow) {
                                size--;
                                allSnow.remove(i);
                                mScene.detachChild(snow);
                            }
                        }
                    }
                }

                tmpInt = randGen.nextInt(5000);

                if (System.currentTimeMillis() - lastRaindropAdd  > tmpInt) {
                    lastRaindropAdd = System.currentTimeMillis();

                    tmpInt = randGen.nextInt(CAMERA_WIDTH);

                    Sprite snow = getRaindrop(tmpInt, 0);
                    allSnow.add(snow);
                    mScene.attachChild(snow);
                }
            }

            @Override
            public void reset() {
            }
        });
        return mScene;
    }

    public void onLoadComplete() {
        // TODO Auto-generated method stub

    }

    public void onPauseGame() {
        // TODO Auto-generated method stub

    }

    public void onResumeGame() {
        // TODO Auto-generated method stub

    }

    public Sprite getRaindrop(float x, float y) {
        return (new Sprite(x, y, snowTexture.deepCopy()));
    }

    @Override
    public boolean onAreaTouched(TouchEvent pSceneTouchEvent,ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) {
        if(pSceneTouchEvent.isActionDown()) {
            // HERE I WANT PLACE CODE, THAT WILL START ANIMATION.
            return true;
        }
        return false;
    }
}

So how to start animation on click? I want to make something like small cartoon.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:27:40+00:00Added an answer on May 28, 2026 at 1:27 am

    In your onLoadScene method after registering update handler disable it.

    mUpdateHandler.setEnabled(false);
    

    And in onAreaTouched method enable it.

    mUpdateHandler.setEnabled(true);
    

    Btw I think it’s not good practice to create Random instance every time in onUpdate method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code like this: public class DatabaseHelper extends SQLiteOpenHelper { private static final
I have code like this: public class Thingy { private final Lock lock =
I have code a bit like this public class MyObject { private bool IsValidDay(ref
Let's say I have code that looks like this: public abstract class ResourceDownloaderBaseImpl implements
I have code that looks like this: template<class T> class list { public: class
Say, I have a code snippet like this: public static void main(String[] args) {
I have code that looks like this: public class A { public void doStuff()
I have code that looks like this: public class Polynomial { List<Term> term =
I have code like this: public class test { public string aa { get;
I have a code like this: [Serializable] public class A { public int X

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.