mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-19 08:16:41 +08:00
[as3] Added event volume and balance, see #1171.
This commit is contained in:
parent
454ecf0c2c
commit
e496bdd6c1
@ -248,7 +248,7 @@ cp -f ../raptor/export/raptor-pro.json ../../spine-starling/spine-starling-examp
|
||||
cp -f ../raptor/export/raptor.atlas ../../spine-starling/spine-starling-example/src/
|
||||
cp -f ../raptor/export/raptor.png ../../spine-starling/spine-starling-example/src/
|
||||
|
||||
cp -f ../spineboy/export/spineboy-ess.json ../../spine-starling/spine-starling-example/src/
|
||||
cp -f ../spineboy/export/spineboy-pro.json ../../spine-starling/spine-starling-example/src/
|
||||
cp -f ../spineboy/export/spineboy.atlas ../../spine-starling/spine-starling-example/src/
|
||||
cp -f ../spineboy/export/spineboy.png ../../spine-starling/spine-starling-example/src/
|
||||
|
||||
|
||||
Binary file not shown.
@ -35,6 +35,8 @@ package spine {
|
||||
public var intValue : int;
|
||||
public var floatValue : Number;
|
||||
public var stringValue : String;
|
||||
public var volume: Number = 1;
|
||||
public var balance: Number = 0;
|
||||
|
||||
public function Event(time : Number, data : EventData) {
|
||||
if (data == null) throw new ArgumentError("data cannot be null.");
|
||||
|
||||
@ -31,10 +31,12 @@
|
||||
package spine {
|
||||
public class EventData {
|
||||
internal var _name : String;
|
||||
public var intValue : int;
|
||||
;
|
||||
public var intValue : int;
|
||||
public var floatValue : Number;
|
||||
public var stringValue : String;
|
||||
public var audioPath: String;
|
||||
public var volume: Number = 1;
|
||||
public var balance: Number = 0;
|
||||
|
||||
public function EventData(name : String) {
|
||||
if (name == null) throw new ArgumentError("name cannot be null.");
|
||||
|
||||
@ -266,6 +266,11 @@ package spine {
|
||||
eventData.intValue = eventMap["int"] || 0;
|
||||
eventData.floatValue = eventMap["float"] || 0;
|
||||
eventData.stringValue = eventMap["string"] || "";
|
||||
eventData.audioPath = eventMap["audio"] || null;
|
||||
if (eventData.audioPath != null) {
|
||||
eventData.volume = eventMap["volume"] || 1;
|
||||
eventData.balance = eventMap["balance"] || 0;
|
||||
}
|
||||
skeletonData.events.push(eventData);
|
||||
}
|
||||
}
|
||||
@ -714,6 +719,10 @@ package spine {
|
||||
event.intValue = eventMap.hasOwnProperty("int") ? eventMap["int"] : eventData.intValue;
|
||||
event.floatValue = eventMap.hasOwnProperty("float") ? eventMap["float"] : eventData.floatValue;
|
||||
event.stringValue = eventMap.hasOwnProperty("string") ? eventMap["string"] : eventData.stringValue;
|
||||
if (eventData.audioPath != null) {
|
||||
event.volume = eventMap.hasOwnProperty("volume") ? eventMap["volume"] : 1;
|
||||
event.balance = eventMap.hasOwnProperty("balance") ? eventMap["balance"] : 0;
|
||||
}
|
||||
eventTimeline.setFrame(frameIndex++, event);
|
||||
}
|
||||
timelines[timelines.length] = eventTimeline;
|
||||
|
||||
Binary file not shown.
@ -50,7 +50,7 @@ package spine.examples {
|
||||
import starling.events.TouchPhase;
|
||||
|
||||
public class SpineboyExample extends Sprite {
|
||||
[Embed(source = "/spineboy-ess.json", mimeType = "application/octet-stream")]
|
||||
[Embed(source = "/spineboy-pro.json", mimeType = "application/octet-stream")]
|
||||
static public const SpineboyJson : Class;
|
||||
|
||||
[Embed(source = "/spineboy.atlas", mimeType = "application/octet-stream")]
|
||||
@ -94,11 +94,12 @@ package spine.examples {
|
||||
trace(entry.trackIndex + " dispose: " + entry.animation.name);
|
||||
});
|
||||
skeleton.state.onEvent.add(function(entry : TrackEntry, event : Event) : void {
|
||||
trace(entry.trackIndex + " event: " + entry.animation.name + ", " + event.data.name + ": " + event.intValue + ", " + event.floatValue + ", " + event.stringValue);
|
||||
trace(entry.trackIndex + " event: " + entry.animation.name + ", " + event.data.name + ": " + event.intValue + ", " + event.floatValue + ", " + event.stringValue + ", " + event.volume + ", " + event.balance);
|
||||
});
|
||||
|
||||
skeleton.skeleton.setToSetupPose();
|
||||
skeleton.state.setAnimationByName(0, "run", true);
|
||||
skeleton.state.setAnimationByName(0, "walk", true);
|
||||
skeleton.state.addAnimationByName(0, "run", true, 2);
|
||||
skeleton.state.addAnimationByName(0, "jump", false, 3);
|
||||
skeleton.state.addAnimationByName(0, "run", true, 0);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user