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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:42:26+00:00 2026-05-28T03:42:26+00:00

I am using this TimerHandler in andEngine to spawn sprites at certain times.. mScene.registerUpdateHandler(new

  • 0

I am using this TimerHandler in andEngine to spawn sprites at certain times..

  mScene.registerUpdateHandler(new TimerHandler(0.02f, true, new ITimerCallback() {
                   @Override
                   public void onTimePassed(TimerHandler pTimerHandler) {
                          addSpriteTime1 += 2; // because timer update = 0.02 seconds
                           if (addSpriteTime1 == nextSprite1Time) {
                                  addFace();
                                   addSpriteTime1 = 0;
                           }

                           addSpriteTime2 += 2;
                           if (addSpriteTime2 == nextSprite2Time) {
                                 addFace2();
                                   addSpriteTime2 = 0;
                           }

                           addSpriteTime3 += 2;
                           if (addSpriteTime3 == nextSprite3Time) {
                                   addFace3();
                                   addSpriteTime3 = 0;
                           }
                   }
           }));

Now i have int variables declared at class level..

private int nextSprite1Time = 100;// initial value, could be changed during game
private int nextSprite2Time = 100;
private int nextSprite3Time = 100;

I then have a method which allows me to change the speed or the nextSpriteTimes.

 private void speed(int f, int g, int h){

    this.nextSprite1Time = f;
    this.nextSprite2Time = g;
    this.nextSprite3Time = h;
    Log.e("Time Changed", String.valueOf(this.nextSprite1Time+ "," + this.nextSprite2Time + ","+ this.nextSprite3Time));

     }

The problem is when i try to change the speed for example..

 speed(30, 50, 70);

It just stops all together and now sprites are added,

Does anyone see where i am going wrong with this or can do it differently?

  • 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-28T03:42:26+00:00Added an answer on May 28, 2026 at 3:42 am

    First of all – Your log message in speed method is not an error – why are you using Log.e method? That’s for errors… Use Log.d (debug) or Log.i (information) instead.

    Back to your problem. I didn’t understand exactly what you meant, but I do see a problem:
    Lets say that nextSprite1Time = 100 and addSpriteTime1 = 70. Up untill here, everything is fine, right? In five more onTimePassed calls, a new sprite will be added.

    But now you changed nextSprite1Time to 60. addSpriteTime1 is still 70, and since it is larger than 60 it will never add a new sprite!

    Solution: Use >= instead of ==, and don’t zero the counters but decrease the value of nextSpriteTime from them, for example, for sprite 1:

    addSpriteTime1 += 2;
    if(addSpriteTime1 >= nextSprite1Time) {
        addFace();
        addSpriteTime1 -= nextSprite1Time;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this: SqlConnection myConnection = new SqlConnection(Data Source=.\\SERVER;Initial Catalog=DB;Integrated Security=True;TrustServerCertificate=True;User Instance=False); myConnection.Open(); SqlCommand myCommand
Using this: MailMessage mm = new MailMessage(); What is the difference between: mm.Sender =
Using this code: xml = new groovy.xml.MarkupBuilder() xmldata = xml.Plugins(nextid: '10') { Target(name: 'default.auth')
Consider this code: using Microsoft.Office.Interop.Word; ApplicationClass _application = new ApplicationClass(); Can I get the
Using this code v=new Date(); var bxx=document.getElementById('bxx'); function t(){ n=new Date(); ss={time}; s=ss-Math.round((n.getTime()-v.getTime())/1000.); m=0;h=0;
Using this code, I need to remove the generated new element. It is not
Using this question as the base is there an alogrithm or coding example to
Using this file as source, I have a situation where I need to retrieve
Using this answer , I created a sample localized app. My question is, is
Using this: Can I use Facebook's fb:friend-selector in an iframe? I created a multi-friend

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.