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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:26:29+00:00 2026-05-26T21:26:29+00:00

I am new at this. Trying to make my first game. I need to

  • 0

I am new at this. Trying to make my first game. I need to time delay transparent pngs to my canvas but cant seem to get it right.

    public LessonsMain(Context context) {
    super(context);
    // TODO Auto-generated constructor stub


     mFujiSensei = getResources().getDrawable(R.drawable.old_man_fuji);
     mFujiSensei.setBounds(0,0,mFujiSensei.getIntrinsicWidth(),mFujiSensei.getIntrinsicHeight());

     mBackground = getResources().getDrawable(R.drawable.lessons_background);
     mBackground.setBounds(0,0,mBackground.getIntrinsicWidth(),mBackground.getIntrinsicHeight());


}

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    mBackground.draw(canvas);

    TimerTask task = new TimerTask() {
        public void run(){
            mFujiSensei.draw(canvas);
        }


    }; timer.schedule(task, 3000);

}

Sorry still dont get it. I tried putting it in a different thread but it still doesnt work.

    public class LessonsMain extends View{

Drawable mBackground;
Drawable mFujiSensei;
Timer timer;
Handler handler;
Runnable runnable;



public LessonsMain(Context context) {
    super(context);
    // TODO Auto-generated constructor stub


     mFujiSensei = getResources().getDrawable(R.drawable.old_man_fuji);
     mFujiSensei.setBounds(0,0,mFujiSensei.getIntrinsicWidth(),mFujiSensei.getIntrinsicHeight());

     mBackground = getResources().getDrawable(R.drawable.lessons_background);
     mBackground.setBounds(0,0,mBackground.getIntrinsicWidth(),mBackground.getIntrinsicHeight());


}

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);
    mBackground.draw(canvas);
    new Thread(new Runnable() {

        @Override
        public void run() {
            // TODO Auto-generated method stub
            TimerTask task = new TimerTask() {
                public void run(){
                    mFujiSensei.draw(canvas);
                }


            }; timer.schedule(task, 3000);
        }

    }).start();


}

}

  • 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-26T21:26:30+00:00Added an answer on May 26, 2026 at 9:26 pm

    The problem here is that when the timerTask executes, it is no longer on the UI thread so it can’t update the view. What you’ll have to do instead ispost to a Handler so the draw can happen on the UI thread. Check out this page for an in-depth explanation of updating the UI from a timer.

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

Sidebar

Related Questions

Well, I'm trying to make a graphical game for the first time, but: BufferedImage
I'm trying to make my first android game and to do this I made
I'm trying to make a new CLLocation subclass. This is the skeleton: #import <UIKit/UIKit.h>
So I'm trying out this new TDD thing (about time haha). Anyways I have
I am new to Django and was trying this code in a tutorial. But
I'm new to this forum, but I've seen it a few times while trying
I'm developing a 3d (first/third person) game and I'm trying to make it multiplayer
I am currently trying to make a game in Android. I have this piece
I'm trying to make my first game, a console tetris. I have a class
So I'm still pretty new to Java and I'm trying to make a game.

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.