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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:01:37+00:00 2026-06-03T07:01:37+00:00

Developing a game with AndEngine GLES2 I am having an issue trying to change

  • 0

Developing a game with AndEngine GLES2

I am having an issue trying to change the scale of a rectangle that I have added to a scene from within a TimerHandlers callback. Whenever the timer ticks it makes a percentage calculation and then within the OnTimePassed ITimerCallback it tries to set the scale of the rectangle in the scene. Unless I declare the rectangle as static I keep getting a nullreferenceexception error.

I know that this is a scope issue, my question is, should I be declaring the objects I need to access from within the timercallback as static or is there an “accepted way” to get access to Activity level objects from within a timercallback?

PlayerRecastTimer = new TimerHandler(0.5f, true, new ITimerCallback(){
    private float recastTime = playerSpellToCast.getRecastTime();

    public void onTimePassed(TimerHandler pTimerHandler) {
        if(recastTime == 0) {
            mAct.GetEngine().unregisterUpdateHandler(pTimerHandler);
            mAct.GetQueue().RemovePlayerSpell();
            pRecast.setScaleX(1);
            RunScene();
        }

        float recastScale;

        recastScale = recastTime / playerSpellToCast.getRecastTime();
        pRecast.setScaleX(recastScale); //blows up here when attempting to scale the rectangle
        recastTime -= 0.5;
    }
});
  • 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-06-03T07:01:38+00:00Added an answer on June 3, 2026 at 7:01 am

    If your PlayerRecastTimer is a member of a class that contains pRecast, then you can reference it using ClassName.this.

    Example: If you have a class named LoadingScreenActivity and it has a rectangle called pRecast, then you can access pRecast in your onTimePassed() function by using

    LoadingScreenActivity.this.pRecast.setScaleX(1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a physics game using AndEngine with box2d physics engine. I have a
While developing a game I have designed a class that in normal operation has
I have been developing a game and I'm confuse that How can I use
I am developing a game and for that I have two different layouts and
I'm developing a game. I want to have game entities each have their own
Im developing a game for Android using AndEngine. As of now, I want to
I am developing a game with andengine. Throughtout my game i place sprites on
I'm developing 2D Side scroll Android Game, using AndEngine and its BOX2D extension. I
I am developing game editor in c++.I have implemented reflection mechanism using DiaSDK.Now I
I am developing game editor in C# that uses c++ lib files. I want

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.