Quantcast
Channel: Question and Answer » libgdx
Viewing all articles
Browse latest Browse all 434

Box2D thow ball from PIXELS posisiton

$
0
0

Here are my enemy movement function. I want that my enemy in random Y-position throw a bunch of things in to the player. And I want to implement physics using Box2D. But I know that Box2D workd only in meters. So how for example my enemy coud throw a ball(BOX2D object (METERS)) into the player from it’s positiion(PIXELS)?

public void update(float dt){
    dtTime += dt;
    if(cont && goTo){
        setBooleans();
        vec.set(saveX - x, saveY - y).nor();
        x += vec.x * speed;
        y += vec.y * speed;
        if(!onWall){
            cont = cont();
        }
    }
}

enter image description here


Viewing all articles
Browse latest Browse all 434

Trending Articles