I want to change Y position of "bucket", when camera Y position is higher than "last created bucket" Y position: There is my code in "create()" method
buckets = new Array<Bucket>();
for(int i=1;i<BUCKET_COUNT;i++){
buckets.add(new Bucket(world,(rand.nextInt((int)W)-45)/PPM,BUCKET_MARGIN*i/PPM));
}
And I am doing like this in "render()" method:
for(Bucket bucket : buckets){
if(cam.position.y > buckets.peek().getBody().getPosition().y){
bucket.repos(rand.nextInt((int)W)/PPM,buckets.size+BUCKET_MARGIN/PPM);
}
}
repos():
public void repos(float x, float y){
setPosition(x, y);//Bucket class is extends Sprite
}
But it doesn't work and I don't know how to solve this problem
I want to know how to get last item from those array?