java - libgdx - moving an object -
so, i'm farely new programming first game, , have been working on while, 1 of classes , i'm creating pong game changed bit , i'm having trouble moving paddle left center everytime change the percentage of width of screen move reason elevates paddle same. controlled width bizarre reason field.height has no effect on moving it? i'm stuck right here , i'm close finishing i'm trying lower paddle bottom center? appreciated , makes sense.
here field
@override public void create () { field.set(0, 0, gdx.graphics.getwidth(), gdx.graphics.getheight()); fieldleft = field.x; fieldright = field.x + field.width; fieldbottom = field.y; fieldtop = field.y + field.height;
and here paddle movement
private void resetrectangle(){ paddle1.move(field.x + (field.width * .5f, 0); paddle2.move(0,0); }
and class
public class paddle extends gameshare{ private shaperenderer paddlerenderer; protected paddle() { super(100, 32); } public void paddlecreate(){ paddlerenderer = new shaperenderer(); } public void paddlerender(float dt){ paddlerenderer.begin(shapetype.filled); drawpaddle(dt); paddlerenderer.end(); } private void drawpaddle(float dt) { paddlerenderer.rect(this.getx(), this.getx(), this.getwidth(), this.getheight()); paddlerenderer.rect(this.getx(), this.getx(), this.getwidth(), this.getheight()); }
Comments
Post a Comment