Using texture() in combination with JBox2D
Posted
by
Valentino Ru
on Game Development
See other posts from Game Development
or by Valentino Ru
Published on 2013-11-05T18:42:55Z
Indexed on
2013/11/05
22:14 UTC
Read the original article
Hit count: 219
I'm getting some trouble using the texture()
method inside beginShape()/endShape()
clause.
In the display()
-method of my class TowerElement (a bar which is DYNAMIC
), I draw the object like following:
void display(){
Vec2 pos = level.getLevel().getBodyPixelCoord(body);
float a = body.getAngle(); // needed for rotation
pushMatrix();
translate(pos.x, pos.y);
rotate(-a);
fill(temp); // temp is a color defined in the constructor
stroke(0);
beginShape();
vertex(-w/2,-h/2);
vertex(w/2,-h/2);
vertex(w/2,h-h/2);
vertex(-w/2,h-h/2);
endShape(CLOSE);
popMatrix();
}
Now, according to the API, I can use the texture()
method inside the shape definition. Now when I remove the fill(temp)
and put texture(img)
(img is a PImage
defined in the constructor), the stroke gets drawn, but the bar isn't filled and I get the warning
texture() is not available with this renderer
What can I do in order to use textures anyway? I don't even understand the error message, since I do not know much about different renderers.
© Game Development or respective owner