Hello! I'm writing a code which is sort of like a variation of Doodle Jump, so I wrote this to create gravity and also make my actor jump when it touches a brick. (Y is the y position of the actor, v is an integer, g is 1, and t is 1. Timer is only to delay the action)
I actually copied the "Actor brick = getWorld().getObjects(Brick.class).get(0)" part from the internet, so I'm not exactly sure how it works...Anyway, the actor only sees one brick, so when I try to jump on to a second brick, it passes right through. So how do you make the actor see more than one brick? Thanks!
public void Gravity(){
if(timer == 5){
Y=Y+V*t;
V=V+g*t;
Actor brick = getWorld().getObjects(Brick.class).get(0);
int By= brick.getY();
int Bx= brick.getX();
if( Y>=By){
if(getX()<Bx+100 & getX()>Bx-100){int delta= Y-By;
Y= By- delta;
V=-V*5/6;}
}
setLocation(getX(), Y);
}
}

