java - Method stops being called -
i made method creates object every time called, spawning stop when boolean variable equal true, when set variable false method spawn characters not called anymore, don't understand since it's on render method should update every frame.
public void update() { deltatime = gdx.graphics.getdeltatime(); timer += 1 * deltatime; if(endgame==false) { //when game starts works. if (timer >= rtime) { newenemy0();//this method spawning timer -= rtime; rtime = rfloat.nextint(3) + 1 * 1f; rposition1 = rfloat.nextint(700) + 1; } }/*when thing happen endgame==true, when click button false when put false nothing happens*/ //this newrnemy method creates new sprite using pools. public void newenemy0(){ sprite enemy= pools.obtain(sprite.class); enemy.setsize(80,80); enemy.setposition(rposition1, 150); enemies.add(enemy); } //i realized endgame doesn't go false when click button: playbutton.addlistener(new inputlistener(){ @override public boolean touchdown(inputevent event, float x, float y, int pointer, int button) { enemyobj.endgame=false; system.out.println(enemyobj.endgame); return super.touchdown(event, x, y, pointer, button); } });// code not updated every frame.
Comments
Post a Comment