Skip to content

Commit 258fdf8

Browse files
committed
Added initial scale to sprite actors
1 parent ac03cb9 commit 258fdf8

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

adventure-composer/src/main/java/com/bladecoder/engineeditor/model/ChapterDocument.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,10 @@ public BaseActor getEngineActor(Element e) {
397397
((SpriteActor) a).getRenderer().setInitAnimation(e.getAttribute("init_animation"));
398398

399399
}
400-
401-
if (e.getAttribute("obstacle").equals("true"))
402-
a.setWalkObstacle(true);
400+
401+
if (!e.getAttribute("scale").isEmpty()) {
402+
((SpriteActor) a).setScale(Float.parseFloat(e.getAttribute("scale")));
403+
}
403404

404405
// PARSE DEPTH TYPE
405406
String depthType = e.getAttribute("depth_type");
@@ -410,6 +411,9 @@ public BaseActor getEngineActor(Element e) {
410411
((SpriteActor) a).setDepthType(DepthType.VECTOR);
411412
}
412413
}
414+
415+
if (e.getAttribute("obstacle").equals("true"))
416+
a.setWalkObstacle(true);
413417

414418
return a;
415419
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public class EditActorDialog extends EditElementDialog {
3838
"Image actors show image files"
3939
};
4040

41-
private InputPanel[] inputs = new InputPanel[12];
41+
private InputPanel[] inputs = new InputPanel[13];
4242
InputPanel typePanel;
4343

4444
String attrs[] = { "type", "id", "layer", "desc", "state", "interaction", "visible",
45-
"walking_speed", "depth_type", "sprite_size", "camera", "fov" };
45+
"walking_speed", "depth_type", "sprite_size", "camera", "fov", "scale" };
4646

4747
@SuppressWarnings("unchecked")
4848
public EditActorDialog(Skin skin, BaseDocument doc, Element parent,
@@ -85,6 +85,10 @@ public EditActorDialog(Skin skin, BaseDocument doc, Element parent,
8585
inputs[11] = new InputPanel(skin, "Camera FOV",
8686
"The camera field of view", Param.Type.FLOAT, true, "49.3",
8787
null);
88+
89+
inputs[12] = new InputPanel(skin, "Scale",
90+
"The sprite scale", Param.Type.FLOAT, true, "1",
91+
null);
8892

8993
setInfo(TYPES_INFO[0]);
9094

@@ -113,13 +117,19 @@ private void typeChanged() {
113117
setVisible(inputs[9],false);
114118
setVisible(inputs[10],false);
115119
setVisible(inputs[11],false);
120+
setVisible(inputs[12],false);
116121

117122
if (ChapterDocument.ACTOR_TYPES[i]
118123
.equals(ChapterDocument.SPRITE3D_ACTOR_TYPE)) {
119124
setVisible(inputs[9],true);
120125
setVisible(inputs[10],true);
121126
setVisible(inputs[11],true);
122127
}
128+
129+
if (!ChapterDocument.ACTOR_TYPES[i]
130+
.equals(ChapterDocument.NO_RENDERER_ACTOR_TYPE)) {
131+
setVisible(inputs[12],true);
132+
}
123133
}
124134

125135
@Override

blade-engine/src/com/bladecoder/engine/loader/ChapterXMLLoader.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ public void startElement(String namespaceURI, String localName,
301301
.getValue("obstacle"));
302302
actor.setWalkObstacle(obstacle);
303303
}
304+
305+
306+
if (atts.getValue("scale") != null && actor instanceof SpriteActor) {
307+
float s = Float
308+
.parseFloat(atts.getValue("scale"));
309+
((SpriteActor)actor).setScale(s);
310+
}
304311

305312
String layerStr = atts.getValue("layer");
306313

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public boolean hit(float x, float y) {
9494
}
9595

9696
public boolean hasInteraction() {
97-
return interaction;
97+
return interaction && visible;
9898
}
9999

100100
public void setInteraction(boolean interaction) {

0 commit comments

Comments
 (0)