Он продолжает говорить, что конструктор не определен. Я уже где-то читал, что мне нужно объявить конструктор без аргументов. Я просто не знаю, как это сделать.У меня ошибка с моим кодом
Если кто-то может помочь, я новичок в Java и программировании. Мой код ниже
package com.alextrost.onscreenjoystickdemo;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.os.Handler;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
public class GameSurface1 extends SurfaceView implements SurfaceHolder.Callback {
private Context _context1;
private GameThread1 _thread1;
private GameControls1 _controls1;
private GameJoystick1 _joystick1;
private Bitmap _pointer;
public GameSurface1(Context context) {
super(context);
// TODO Auto-generated constructor stub
_context1 = context;
init1();
}
private void init1(){
SurfaceHolder holder = getHolder();
holder.addCallback(this);
// A call will be made to start it later
_thread1 = new GameThread1(holder, _context1, new Handler(),this);
setFocusable(true);
_joystick1 = new GameJoystick1(getContext().getResources());
_pointer = (Bitmap)BitmapFactory.decodeResource(getResources(), R.drawable.icon);
//controls
_controls1 = new GameControls1();
setOnTouchListener(_controls1);
}
public void doDraw1(Canvas canvas){
//update the pointer
_controls1.update(null);
//draw the pointer
canvas.drawBitmap(_pointer, _controls1._pointerPosition1.x, _controls1._pointerPosition1.y, null);
//draw the joystick background
canvas.drawBitmap(_joystick1.get_joystickBg(), 50,220, null);
//draw the dragable joystick
canvas.drawBitmap(_joystick1.get_joystick(),_controls1._touchingPoint1.x -357, _controls1._touchingPoint1.y -26, null);
}
//these methods are overridden from the SurfaceView super class. They are automatically called
//when a SurfaceView is created, resumed or suspended.
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {}
private boolean retry1;
@Override
public void surfaceDestroyed(SurfaceHolder arg0) {
retry1 = true;
//code to end gameloop
_thread1.state1 = GameThread.STOPED;
while (retry1) {
try {
//code to kill Thread
_thread1.join();
retry1 = false;
} catch (InterruptedException e) {
}
}
}
@Override
public void surfaceCreated(SurfaceHolder arg0) {
if(_thread1.state1==GameThread1.PAUSED){
//When game is opened again in the Android OS
_thread1 = new GameThread1(getHolder(), _context1, new Handler(),this);
_thread1.start();
}else{
//creating the game Thread for the first time
_thread1.start();
}
}
public void Update() {
// TODO Auto-generated method stub
}
}
Пожалуйста, всегда добавить сообщение об ошибке в вашем вопросе. –