Skip to content

Commit 93c2843

Browse files
committed
fixes: atlas drawing with spripspaces + parallax
1 parent 573d16b commit 93c2843

File tree

5 files changed

+34
-8
lines changed

5 files changed

+34
-8
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/EditActorDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public void changed(ChangeEvent event, Actor actor) {
155155
}
156156
});
157157

158-
init(parent, e, new InputPanel[] { typePanel, id, layer, visible, interaction, desc, state, renderer, depthType,
158+
init(parent, e, new InputPanel[] { typePanel, id, renderer, layer, visible, interaction, desc, state, depthType,
159159
scale, zIndex, walkingSpeed, spriteSize, cameraName, fov, textColor });
160160

161161
typeChanged();

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/EditSceneDialog.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class EditSceneDialog extends EditModelDialog<World, Scene> {
6868
private InputPanel loopMusic;
6969
private InputPanel initialMusicDelay;
7070
private InputPanel repeatMusicDelay;
71+
private InputPanel sceneSize;
7172

7273
@SuppressWarnings("unchecked")
7374
public EditSceneDialog(Skin skin, World parent, Scene e) {
@@ -91,6 +92,9 @@ public EditSceneDialog(Skin skin, World parent, Scene e) {
9192
"The time to wait before playing", Param.Type.FLOAT, true, "0");
9293
repeatMusicDelay = InputPanelFactory.createInputPanel(skin, "Repeat music delay",
9394
"The time to wait before repetitions", Param.Type.FLOAT, true, "0");
95+
96+
sceneSize = InputPanelFactory.createInputPanel(skin, "Scene Dimension",
97+
"Sets the size of the scene. If empty, the background image size is used as the scene dimension.", Param.Type.DIMENSION, false);
9498

9599
bgImage = new Image();
96100
bgImage.setScaling(Scaling.fit);
@@ -123,7 +127,7 @@ public void changed(ChangeEvent event, Actor actor) {
123127
}
124128

125129
init(parent, e, new InputPanel[] { id, backgroundAtlas, backgroundRegion,
126-
depthVector, state, music, loopMusic, initialMusicDelay, repeatMusicDelay });
130+
depthVector, state, sceneSize, music, loopMusic, initialMusicDelay, repeatMusicDelay });
127131
}
128132

129133
private void showBgImage(String r) {
@@ -209,6 +213,8 @@ protected void inputsToModel(boolean create) {
209213

210214
e.setMusic(music.getText(), Boolean.parseBoolean(loopMusic.getText()),
211215
Float.parseFloat(initialMusicDelay.getText()), Float.parseFloat(repeatMusicDelay.getText()));
216+
217+
e.setSceneSize(Param.parseVector2(sceneSize.getText()));
212218

213219
parent.addScene(e);
214220

@@ -238,6 +244,9 @@ protected void modelToInputs() {
238244
loopMusic.setText(Boolean.toString(e.isLoopMusic()));
239245
initialMusicDelay.setText(Float.toString(e.getInitialMusicDelay()));
240246
repeatMusicDelay.setText(Float.toString(e.getRepeatMusicDelay()));
247+
248+
if (e.getSceneSize() != null)
249+
sceneSize.setText(Param.toStringParam(e.getSceneSize()));
241250
}
242251

243252
private String[] getAtlasList() {

blade-engine/src/com/bladecoder/engine/anim/AnimationDesc.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.HashMap;
1919

2020
import com.badlogic.gdx.math.Vector2;
21-
import com.bladecoder.engine.util.EngineLogger;
2221

2322
public class AnimationDesc {
2423
public final static String BACK = "back";
@@ -96,7 +95,7 @@ public static String getDirectionString(Vector2 p0, Vector2 pf, int numDirs) {
9695
if (ratio2 < 1.0)
9796
ratio2 = 1.0f / ratio;
9897

99-
EngineLogger.debug("P0: " + p0 + " PF: " + pf + " dx: " + dx + " dy: " + dy + " RATIO: " + ratio);
98+
// EngineLogger.debug("P0: " + p0 + " PF: " + pf + " dx: " + dx + " dy: " + dy + " RATIO: " + ratio);
10099

101100
if (ratio2 < DIRECTION_ASPECT_TOLERANCE && numDirs > 4) { // DIAGONAL
102101
// MOVEMENT

blade-engine/src/com/bladecoder/engine/model/AtlasRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public void draw(SpriteBatch batch, float x, float y, float scale) {
127127
batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY, tex.packedWidth, tex.packedHeight, scale,
128128
scale, 0);
129129
} else {
130-
batch.draw(tex, x + tex.packedWidth * scale, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY, -tex.packedWidth,
131-
tex.packedHeight, scale, scale, 0);
130+
batch.draw(tex, x, y, tex.originalWidth / 2 - tex.offsetX, tex.originalHeight / 2 - tex.offsetY, tex.packedWidth, tex.packedHeight, -scale,
131+
scale, 0);
132132
}
133133
}
134134

blade-engine/src/com/bladecoder/engine/model/Scene.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public class Scene implements Serializable, AssetConsumer {
8888
private String musicFilename;
8989
private boolean isPlayingSer = false;
9090
private float musicPosSer = 0;
91+
private Vector2 sceneSize;
9192

9293
transient private boolean isMusicPaused = false;
9394

@@ -620,12 +621,16 @@ public void retrieveAssets() {
620621
int height = background.get(0).getRegionHeight();
621622

622623
// Sets the scrolling dimensions. It must be done here because
623-
// the background must be loaded to calculate the bbox
624-
camera.setScrollingDimensions(width, height);
624+
// the background must be loaded to calculate the bbox
625+
if(sceneSize == null)
626+
camera.setScrollingDimensions(width, height);
625627

626628
// if(followActor != null)
627629
// camera.updatePos(followActor);
628630
}
631+
632+
if(sceneSize != null)
633+
camera.setScrollingDimensions(sceneSize.x, sceneSize.y);
629634

630635
// RETRIEVE ACTORS
631636
for (BaseActor a : actors.values()) {
@@ -667,6 +672,14 @@ public void dispose() {
667672
}
668673
}
669674

675+
public Vector2 getSceneSize() {
676+
return sceneSize;
677+
}
678+
679+
public void setSceneSize(Vector2 sceneSize) {
680+
this.sceneSize = sceneSize;
681+
}
682+
670683
public void orderLayersByZIndex() {
671684
for (SceneLayer l : layers) {
672685
l.orderByZIndex();
@@ -707,6 +720,9 @@ public void write(Json json) {
707720

708721
if (polygonalNavGraph != null)
709722
json.writeValue("polygonalNavGraph", polygonalNavGraph);
723+
724+
if (sceneSize != null)
725+
json.writeValue("sceneSize", sceneSize);
710726

711727
} else {
712728
SceneActorRef actorRef;
@@ -775,6 +791,8 @@ public void read(Json json, JsonValue jsonData) {
775791
depthVector = json.readValue("depthVector", Vector2.class, jsonData);
776792

777793
polygonalNavGraph = json.readValue("polygonalNavGraph", PolygonalNavGraph.class, jsonData);
794+
795+
sceneSize = json.readValue("sceneSize", Vector2.class, jsonData);
778796

779797
} else {
780798
JsonValue jsonValueActors = jsonData.get("actors");

0 commit comments

Comments
 (0)