Every time Compile APK into Android Phone, It Keep Stop Working?!

edited July 2017 in Android Mode

I had sought the answer from everywhere but there was not the solution at all and it makes me kinda upset. Even though I tried my friend's phone but it still stops working as well when I tried to run the game. The game only can play in Java mode. Could someone please help get me out of this? (The game genre similar to flappy bird as well).

processing version - processing 3.3.5

android version - API 8.0.0(26)

operating system - Windows 10 Enterprise 64-bit

processing file link here: https://www.dropbox.com/s/s1hokayheh3vv25/flyFarBird.rar?dl=0

PFont bitoem;
PImage birdImg, bgImg, obsImg, menuImg, startBtn;
int score = 0, highScore = 0, genestate = 1, x = -200, y, vy = 0,  wx[] = new int[2], wy[] = new int[2];
import ddf.minim.*;

AudioPlayer playerBGM, playerSwing, playerDie, playerScore;
Minim minim; 

void setup() {
  fullScreen(P2D);
  //size(600 , 800);  
  //game images
  birdImg = loadImage("chosenBird_8Bit.png");
  bgImg = loadImage("background_color002(1680x800).jpg");
  obsImg = loadImage("obstacle_long.jpg");
  menuImg = loadImage("startMenu.jpg");
  startBtn = loadImage("startBtn.jpg");
  bitoem = loadFont("8BITWONDERNominal-48.vlw");

  //music & sfx
  minim = new Minim(this);
  playerBGM = minim.loadFile("Jextor.mp3", 128);
  playerBGM.play();
  playerBGM.setGain(-10.0);
  playerBGM.loop();

  playerSwing = minim.loadFile("sfx_wing.wav", 705);


  playerScore = minim.loadFile("sfx_point.wav");

  playerDie = minim.loadFile("sfx_hit.wav");


  //fonts style
  textFont(bitoem, 24);
  fill(255,255,255);
  textSize(28);

}

void draw() { //runs 60 times a second
  //background image loop
  if(genestate == 0) {
    //background(255,255,255);
    imageMode(CORNER);
    image(bgImg, x, 0);
    image(bgImg, x+bgImg.width, 0);

    x -= 3;
    vy += 1;
    y += vy;

    if(x == -1680) x=0;

    //generate obstacle imgs
    for(int i = 0; i < 2; i++){
      imageMode(CENTER);
      image(obsImg, wx[i], wy[i] - ((obsImg.height/2)+100));
      image(obsImg, wx[i], wy[i] + (obsImg.height/2+100));
      if(wx[i] < 0 ){
        wy[i] = (int)random(200,height -200);
        wx[i] = width;
      }

      //accumulative score
      if(wx[i] == width/2){
        playerScore.play();
        playerScore = minim.loadFile("sfx_point.wav");
        highScore = max(++score, highScore);
      }

      //bird image touch obstacle img, it will goes to genestate1
      if(y>height || y<0 || (abs(width/2-wx[i])<25 && abs(y-wy[i]) > 100))
      genestate=1;
      wx[i] -= 6;


    }

    image(birdImg, width/2, y, 46, 30.5);

    //calculate the score while middle pixel goes through the pipe
    text(""+score, width/2-15, 70);
  }

  else{
      imageMode(CENTER);
      image(menuImg, width/2, height/2);
      image(startBtn, width/2, 500); 
      text(highScore, 350, width/2-15);

   }
}

void mousePressed(){
  vy =- 17;


  if(genestate == 1){
    wx[0] = 600;
    wy[0] = y = height/2;
    wx[1] = 900;
    wy[1] = 600;
    x = genestate = score = 0;    
  }

}

void mouseClicked(){
  if(genestate == 0){
    playerSwing.play();
  }
}

void mouseReleased(){
  playerSwing.close();
  playerSwing = minim.loadFile("sfx_wing.wav", 705);
}

void stop(){
  playerBGM.close();
  minim.stop();
  super.stop();

}

Answers

  • edit post, highlight code, press ctrl-o to format.

    processing version?

    android version?

    operating system?

  • edited July 2017

    alright, thanks for your kind advice.

  • Answer ✓

    minim doesn't work on android afaik.

  • btw

        playerScore = minim.loadFile("sfx_point.wav");
    

    don't load files during the main loop, it's too expensive and will cause slowdown. load them all in setup.

  • Answer ✓

    I don't think minim works in android mode. Generally, if you code in Processing-java, you can run the same sketch in Android mode. However, if you use external libraries, you need to check if those libraries are compatible in Android mode. Last time I checked, minim does not work under android. For playing music files, you can use the cassette library available under the Library Manager in the Processing IDE. For more advanced stuff, you will need to use MediaPlayer directly from the Android API. You can check prev posts: https://forum.processing.org/two/search?Search=MediaPlayer

    Kf

  • @koogs @kfrajer, dude it's a really big help for me T^T. Thanks anyway

Sign In or Register to comment.