progress on flake entity
This commit is contained in:
parent
4ada07bcd4
commit
c33947ef5f
@ -30,29 +30,26 @@ public class Flake extends Actor implements Poolable, Entity {
|
||||
|
||||
public void init(float x, float y, float rate, float fuse, float angle, Shard... shards) {
|
||||
this.shards = shards;
|
||||
setPosition(x, y);
|
||||
setSize(1f, 1f);
|
||||
this.rate = rate;
|
||||
this.timer = fuse;
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
setPosition(x-center.x, y-center.y);
|
||||
rot.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
debug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
moveBy(rot.x*delta*rate, rot.y*delta*rate);
|
||||
|
||||
if (timer > 0) {
|
||||
timer -= delta;
|
||||
}
|
||||
|
||||
moveBy(rot.x*delta*rate, rot.y*delta*rate);
|
||||
|
||||
for (int i = 0; i < shards.length; i++) {
|
||||
shards[i].debug();
|
||||
shards[i].setPosition(getX()+center.x-shards[i].getCenter().x, getY()+center.y-shards[i].getCenter().y);
|
||||
}
|
||||
|
||||
hitbox.setPosition(getX(), getY());
|
||||
|
||||
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
|
||||
@ -63,7 +60,7 @@ public class Flake extends Actor implements Poolable, Entity {
|
||||
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
batch.draw(texture, getX(), getY());
|
||||
batch.draw(texture, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
||||
@ -103,7 +100,6 @@ public class Flake extends Actor implements Poolable, Entity {
|
||||
setSize(0, 0);
|
||||
center.set(0, 0);
|
||||
rot.set(0, 0);
|
||||
System.out.println("iscleaned");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Shard extends Actor implements Entity, Poolable {
|
||||
setSize(2f, 2f);
|
||||
hitbox.setSize(getWidth(), getHeight());
|
||||
center.set(getWidth()/2f, getHeight()/2f);
|
||||
setPosition(x, y);
|
||||
setPosition(x-center.x, y-center.y);
|
||||
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
||||
}
|
||||
|
||||
@ -111,11 +111,6 @@ public class Shard extends Actor implements Entity, Poolable {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(float x, float y) {
|
||||
super.setPosition(x-center.x, y-center.y);
|
||||
}
|
||||
|
||||
public Vector2 getCenter() {
|
||||
return center;
|
||||
}
|
||||
|
@ -102,8 +102,6 @@ public class SpawnerWindow extends Window {
|
||||
stage.addActor(shards[i]);
|
||||
}
|
||||
|
||||
System.out.println("test");
|
||||
|
||||
Flake flake = (Flake) entity;
|
||||
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, shards);
|
||||
stage.addActor(flake);
|
||||
|
Loading…
Reference in New Issue
Block a user