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);
|
Entity e = new Entity(name, hitbox, drawbox);
|
||||||
|
hitbox.setOwnerEntity(e);
|
||||||
e.setType(solid);
|
e.setType(solid);
|
||||||
logger.finer("Entity \""+name+"\" was created.");
|
logger.finer("Entity \""+name+"\" was created.");
|
||||||
Project.getInstance().addEntity(e);
|
Project.getInstance().addEntity(e);
|
||||||
|
|||||||
@ -11,13 +11,11 @@ public class Entity {
|
|||||||
private int width = 0;
|
private int width = 0;
|
||||||
private int height = 0;
|
private int height = 0;
|
||||||
|
|
||||||
|
|
||||||
public Entity(String name, String drawbox, String hitbox, BufferedImage sprite) {
|
public Entity(String name, String drawbox, String hitbox, BufferedImage sprite) {
|
||||||
thisName = new String(name);
|
thisName = new String(name);
|
||||||
thisDrawbox = new Drawbox(drawbox);
|
thisDrawbox = new Drawbox(drawbox);
|
||||||
setImage(sprite); // updates entity width and height, should be called before creating hitbox
|
setImage(sprite); // updates entity width and height, should be called before creating hitbox
|
||||||
thisHitbox = new Hitbox(hitbox);
|
thisHitbox = new Hitbox(hitbox,this);
|
||||||
thisHitbox.setOwnerEntity(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entity(String name, Hitbox hitbox, Drawbox drawbox) {
|
public Entity(String name, Hitbox hitbox, Drawbox drawbox) {
|
||||||
|
|||||||
@ -21,8 +21,9 @@ public class Hitbox {
|
|||||||
this.listPointsCartesian = listPointsCartesian;
|
this.listPointsCartesian = listPointsCartesian;
|
||||||
initListsPoints();
|
initListsPoints();
|
||||||
}
|
}
|
||||||
public Hitbox(String informationHitbox){
|
public Hitbox(String informationHitbox, Entity owner){
|
||||||
if(informationHitbox!= null) {
|
if(informationHitbox!= null) {
|
||||||
|
setOwnerEntity(owner);
|
||||||
initListsPoints();
|
initListsPoints();
|
||||||
String[] informations = informationHitbox.split(" ");
|
String[] informations = informationHitbox.split(" ");
|
||||||
//в 0-м индексе всегда идет название фигуры.Так сделан наш xml.
|
//в 0-м индексе всегда идет название фигуры.Так сделан наш xml.
|
||||||
@ -85,7 +86,7 @@ public class Hitbox {
|
|||||||
}
|
}
|
||||||
//+++++++
|
//+++++++
|
||||||
private void createCartesianPointsFromWidthAndHeigh(){
|
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));
|
Point refCartesianPoint = isometricToCartesian(refIsoPoint.x,refIsoPoint.y,new Point(0,0));
|
||||||
listPointsCartesian.clear();
|
listPointsCartesian.clear();
|
||||||
listPointsCartesian.add(new Point(refCartesianPoint.x-widthHitbox,refCartesianPoint.y));
|
listPointsCartesian.add(new Point(refCartesianPoint.x-widthHitbox,refCartesianPoint.y));
|
||||||
|
|||||||
Reference in New Issue
Block a user