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 6769607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:48+00:00 2026-05-26T15:12:48+00:00

I am using AndEngine. I have a Method that adds targets to the screne.

  • 0

I am using AndEngine.

I have a Method that adds targets to the screne.

Here is my method..

public void addTarget(){
    /*
     * We are determining the minimum and maximum y position for the targets to appear at then
     * use the Random() class to generate a random number so the value of y is
     * still on the screen while the x value replaces the sprite just before the right side or the screen.
     * 
     */
    Random rand = new Random();

    int x = (int) mCamera.getWidth() + mTargetTextureRegion.getWidth();
    int minY = mTargetTextureRegion.getHeight();
    int maxY = (int)(mCamera.getHeight() - mTargetTextureRegion.getHeight());
    int rangeY = maxY - minY;
    int y = rand.nextInt(rangeY) + minY;

    Sprite target = new Sprite(x,y,mTargetTextureRegion.clone());
    SceneMainScene.attachChild(target);

    int minDuration = 2;
    int maxDuration = 4;

    int rangeDuration = maxDuration - minDuration;
    int actualDuration = rand.nextInt(rangeDuration) + minDuration;

    MoveXModifier mod = new MoveXModifier(actualDuration, target.getX(), - target.getWidth());

    target.registerEntityModifier(mod);
    TargetsToBeAdded.add(target);

It works fine. The only problem i am having is that the Targets come onto the screen from left to right.. I would like to change this so the Targets are displayed from top to bottom?

I cant figure out in my code what i need to change to do this? Any suggestions?

  • 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-26T15:12:48+00:00Added an answer on May 26, 2026 at 3:12 pm

    You are using a

    MoveXModifier mod = new MoveXModifier(actualDuration, target.getX(), - target.getWidth());
    

    try using a

    MoveYModifier mod = new MoveYModifier(actualDuration, target.getY(), - target.getHeight());
    

    In AndEngine (0,0) is the top left corner, X increase going to the right and Y increase going down

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

Sidebar

Related Questions

I have a method in engine i'm using (andengine) : public final void setText(String
I am using andengine and I have some sprites that change color when pressed.
I have an AppEngine app that I'm migrating to run in Django, using app-engine-patch
I have a app with a kind of rest api that I'm using to
I'm developing a physics game using AndEngine with box2d physics engine. I have a
I have this method in my RPC service: @Override public Entrata[] getEntrate(int from, int
I'm using AndEngine to create a live wallpaper and SharedPreferences for the settings. Here
I'm using AndEngine to create a Live Wallpaper and I have everything set up
I am using java + AndEngine in my game. During the game i have
I am using AndEngine to create a game. I have randomly added sprites in

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.