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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:14:05+00:00 2026-05-26T12:14:05+00:00

i have problems with my game. I have an Main Activity that’s shows a

  • 0

i have problems with my game. I have an Main Activity that’s shows a surfaceview where i draw my game. Now i want to pass data from my Main Activity to a Class but everytime i try this i got an Error and in the LogCat i see that the error happens on the line where i pass the data. here my Code
MainActivity:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main);
}
public boolean onTouchEvent(MotionEvent event) {
            currentX = event.getX();
    currentY = event.getY();
    if(event.getAction() == MotionEvent.ACTION_DOWN){
        touchDisplay = true;
        banka = new Banka(currentX, currentY, touchDisplay);
    }
    if(event.getAction() == MotionEvent.ACTION_UP){
        touchDisplay = false;
        banka = new Banka(currentX, currentY, touchDisplay);
    }
    return super.onTouchEvent(event);
}

Class that received the data:

public class Banka {
public GameView gameView;

public float currentX = 0;
public float currentY = 0;
public boolean touchDownTrue = false;

public Banka (float x, float y, boolean touch){
    this.currentX = x;
    this.currentY = y;
    this.touchDownTrue = touch;
    gameView.isReady();
}

and here my LogCat error:

here the logcat:

thread exiting with uncaught exception (group=0x4001b188) Uncaught
handler: thread main exiting due to uncaught exception
java.lang.NullPointerException at
com.whlabs.nameless.Banka.(Banka.java:14) at
com.whlabs.nameless.MainActivity.onTouchEvent(MainActivity.java:31) at
android.app.Activity.dispatchTouchEvent(Activity.java:2064) at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
at android.view.ViewRoot.handleMessage(ViewRoot.java:1691) at
android.os.Handler.dispatchMessage(Handler.java:99) at
android.os.Looper.loop(Looper.java:123) at
android.app.ActivityThread.main(ActivityThread.java:4363) at
java.lang.reflect.Method.invokeNative(Native Method) at
java.lang.reflect.Method.invoke(Method.java:521) at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at
dalvik.system.NativeStart.main(Native Method)

  • 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-26T12:14:06+00:00Added an answer on May 26, 2026 at 12:14 pm

    I’m guessing your getting a NullPointerException because you’re not initializing gameView. One way to fix this is to initialize gameView in your constructor like so:

    public Banka (float x, float y, boolean touch){
        this.currentX = x;
        this.currentY = y;
        this.touchDownTrue = touch;
        gameView = new GameView();
        gameView.isReady();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two activities. One activity has the main game and the other activity
I have written a game that uses GLUT, OpenGL and FMOD. The problem is
I have problems with dealing with widows within a multicols environment, that is, I
I have problems getting some of my views aligned in a relative layout that
I have a simple iPhone game consisting of two threads: the main game loop
I have 3 screens(xmls): screen 1 is main menu, screen 2 is main game
I'm new to XNA and I'm building an Asteroids game. I have some problems
I have a normal map in my OpenGL game engine and I realized that
I am writing a small game, with one JFrame that holds the main game,
I'm working on a small game and I'm having problems changing my Activity's content

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.