vendredi 5 juin 2015

spawn at random position Android

i have problem with Android. I'm trying make project that i draw circles on random position. After touch on this circle you will get score and circle will disapear. But i have problem that my object is spawn then disapear without touch and spawn i other location. Here is my spawner code.

protected void spawner(Canvas canvas,int timer){
    System.out.println(myThread.timer);
if (myThread.timer>100) {
    int x = 200 - generator.nextInt() % (myThread.screenDimX / 2);
    int y = 200 - generator.nextInt() % (myThread.screenDimY / 2);
    Paint paint = new Paint();
    paint.setStyle(Paint.Style.FILL);
    paint.setColor(Color.WHITE);
    paint.setColor(Color.parseColor("#800000"));
    canvas.drawCircle(x, y,50, paint);
    myThread.timer=0;
}
}

myThread it is my gameloop thread. can anyone help me with this? :<




Aucun commentaire:

Enregistrer un commentaire