by
386 12

SNIPPET - Box2d_LibGdx_Integration

Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/198653/SNIPPET---Box2d_LibGdx_Integration?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
/* <SNIPPET> <TAGS = "JAVA,LIBGDX,BOX2D" /> <NAME="Box2d_LibGdx_Integration" /> <DESCR>Codice per integrare una texture region con un oggetto Box2D</DESCR> </SNIPPET> */ public TextureWrapper{ TextureRegion region; int width; int height; Vector2 position; float scaleX; float scaleY; float originX; float originY; float rotation; public TextureWrapper(TextureRegion region,Vector2 pos){ this.position=pos; SetTextureRegion(region); } public void SetTextureRegion(TextureRegion region){ this.region=region; width=region.getRegionWidth(); height=region.getRegionHeight(); originX=width/2; originY=height/2; scaleX=1; scaleY=1; } public int GetWidth(){ return width; } public int GetHeight(){ return height; } public void SetPosition(float x,float y){ position.set(x,y); } public void SetRotation(float r){ rotation=r; } public void Draw(SpriteBatch sp){ sp.draw(region,position.x-width/2, position.y-height/2, originX, originY, width, height, scaleX, scaleY, rotation); } .... } public class BoxUserData{ int collisionGroup; int boxId; public BoxUserData(int boxid,int collisiongroup){ Set(boxid,collisiongroup); } public void Set(int boxid,int collisiongroup){ this.boxId=boxid; this.collisionGroup=collisiongroup; } public int GetBoxId(){ return this.boxId; } public int GetCollisionGroup{ return this.collisionGroup; } }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus