Hitbox edits for new Entity fields
This commit is contained in:
@ -100,6 +100,7 @@ public class ListGUI extends JPanel {
|
||||
|
||||
// а тут уже создание новой сущности
|
||||
Entity e = new Entity(name, hitbox, drawbox);
|
||||
hitbox.setOwnerEntity(e);
|
||||
e.setType(solid);
|
||||
logger.finer("Entity \""+name+"\" was created.");
|
||||
Project.getInstance().addEntity(e);
|
||||
|
||||
@ -10,14 +10,12 @@ public class Entity {
|
||||
private BufferedImage thisImage;
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
|
||||
|
||||
public Entity(String name, String drawbox, String hitbox, BufferedImage sprite) {
|
||||
thisName = new String(name);
|
||||
thisDrawbox = new Drawbox(drawbox);
|
||||
setImage(sprite); // updates entity width and height, should be called before creating hitbox
|
||||
thisHitbox = new Hitbox(hitbox);
|
||||
thisHitbox.setOwnerEntity(this);
|
||||
thisHitbox = new Hitbox(hitbox,this);
|
||||
}
|
||||
|
||||
public Entity(String name, Hitbox hitbox, Drawbox drawbox) {
|
||||
|
||||
@ -21,8 +21,9 @@ public class Hitbox {
|
||||
this.listPointsCartesian = listPointsCartesian;
|
||||
initListsPoints();
|
||||
}
|
||||
public Hitbox(String informationHitbox){
|
||||
public Hitbox(String informationHitbox, Entity owner){
|
||||
if(informationHitbox!= null) {
|
||||
setOwnerEntity(owner);
|
||||
initListsPoints();
|
||||
String[] informations = informationHitbox.split(" ");
|
||||
//в 0-м индексе всегда идет название фигуры.Так сделан наш xml.
|
||||
@ -85,7 +86,7 @@ public class Hitbox {
|
||||
}
|
||||
//+++++++
|
||||
private void createCartesianPointsFromWidthAndHeigh(){
|
||||
Point refIsoPoint = new Point(owner.getImage().getWidth()/2+referencePoint.x,owner.getImage().getHeight()+referencePoint.y);
|
||||
Point refIsoPoint = new Point(owner.getWidth()/2+referencePoint.x,owner.getHeight()+referencePoint.y);
|
||||
Point refCartesianPoint = isometricToCartesian(refIsoPoint.x,refIsoPoint.y,new Point(0,0));
|
||||
listPointsCartesian.clear();
|
||||
listPointsCartesian.add(new Point(refCartesianPoint.x-widthHitbox,refCartesianPoint.y));
|
||||
|
||||
Reference in New Issue
Block a user