Nem Posted May 14, 2014 Report Share Posted May 14, 2014 Is there a getWidth / getHeight method using the Trixt0r Java importer api? I am attempting to implement the api but I need to getWidth/getHeight so I can offset for player size when determining collision with a specific tile (tmx Tile maps) I like to use this simple collision check in addition to other forms of collision with objects. This is kind of what I want to do...I check to see if movement is allowed here: public boolean canPlayerMove(float x, float y) { boolean movementAllowed = true; // offset for player size. x += getWidth()/1.5f; y += getHeight() / 4; if (isCellBlocked(x,y)) { movementAllowed = false; } return movementAllowed; } Quote Link to comment Share on other sites More sharing options...
Trixt0r Posted May 14, 2014 Report Share Posted May 14, 2014 Use Rectangle rect = getBoundingRectangle(null);float width = rect.size.width;float height = rect.size.height;//Do stuff getBoundingRectangle() returns always the same object reference! But you should know that calculating the rectangle of a player can give you many different results, because not every animation has the same bounding box. You could use boxes in Spriter instead. Those will give you always the same size. -Trixt0r Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.