Skip to content

Instantly share code, notes, and snippets.

@honebito
Created June 15, 2019 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save honebito/387b7ab6e92d0a55d177aa6a6c31a2cf to your computer and use it in GitHub Desktop.
Save honebito/387b7ab6e92d0a55d177aa6a6c31a2cf to your computer and use it in GitHub Desktop.
AnimateCCで出力されるJSファイル
(function (cjs, an) {
var p; // shortcut to reference prototypes
var lib={};var ss={};var img={};
lib.ssMetadata = [
{name:"sample_atlas_", frames: [[0,0,492,458]]}
];
// symbols:
(lib.charcter = function() {
this.initialize(ss["sample_atlas_"]);
this.gotoAndStop(0);
}).prototype = p = new cjs.Sprite();
// helper functions:
function mc_symbol_clone() {
var clone = this._cloneProps(new this.constructor(this.mode, this.startPosition, this.loop));
clone.gotoAndStop(this.currentFrame);
clone.paused = this.paused;
clone.framerate = this.framerate;
return clone;
}
function getMCSymbolPrototype(symbol, nominalBounds, frameBounds) {
var prototype = cjs.extend(symbol, cjs.MovieClip);
prototype.clone = mc_symbol_clone;
prototype.nominalBounds = nominalBounds;
prototype.frameBounds = frameBounds;
return prototype;
}
(lib.charcter_レイヤー_1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// レイヤー_1
this.instance = new lib.charcter();
this.instance.parent = this;
this.instance.setTransform(-246,-229);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
}).prototype = getMCSymbolPrototype(lib.charcter_レイヤー_1, null, null);
(lib.charcter_1 = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// レイヤー_1_obj_
this.レイヤー_1 = new lib.charcter_レイヤー_1();
this.レイヤー_1.name = "レイヤー_1";
this.レイヤー_1.parent = this;
this.レイヤー_1.depth = 0;
this.レイヤー_1.isAttachedToCamera = 0
this.レイヤー_1.isAttachedToMask = 0
this.レイヤー_1.layerDepth = 0
this.レイヤー_1.layerIndex = 0
this.レイヤー_1.maskLayerName = 0
this.timeline.addTween(cjs.Tween.get(this.レイヤー_1).wait(1));
}).prototype = getMCSymbolPrototype(lib.charcter_1, new cjs.Rectangle(-246,-229,492,458), null);
(lib.シーン_1_charcter = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
// charcter
this.mc_charcter = new lib.charcter_1();
this.mc_charcter.name = "mc_charcter";
this.mc_charcter.parent = this;
this.mc_charcter.setTransform(512,384);
this.timeline.addTween(cjs.Tween.get(this.mc_charcter).wait(1));
}).prototype = getMCSymbolPrototype(lib.シーン_1_charcter, null, null);
// stage content:
(lib.sample = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});
this.___GetDepth___ = function(obj) {
var depth = obj.depth;
var cameraObj = this.___camera___instance;
if(cameraObj && cameraObj.depth && obj.isAttachedToCamera)
{
depth += depth + cameraObj.depth;
}
return depth;
}
this.___needSorting___ = function() {
for (var i = 0; i < this.getNumChildren() - 1; i++)
{
var prevDepth = this.___GetDepth___(this.getChildAt(i));
var nextDepth = this.___GetDepth___(this.getChildAt(i + 1));
if (prevDepth < nextDepth)
return true;
}
return false;
}
this.___sortFunction___ = function(obj1, obj2) {
return (this.exportRoot.___GetDepth___(obj2) - this.exportRoot.___GetDepth___(obj1));
}
this.on('tick', function (event){
var curTimeline = event.currentTarget;
if (curTimeline.___needSorting___()){
this.sortChildren(curTimeline.___sortFunction___);
}
});
// timeline functions:
this.frame_0 = function() {
this.mc_charcter = this.charcter.mc_charcter;
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
// charcter_obj_
this.charcter = new lib.シーン_1_charcter();
this.charcter.name = "charcter";
this.charcter.parent = this;
this.charcter.setTransform(512,384,1,1,0,0,0,512,384);
this.charcter.depth = 0;
this.charcter.isAttachedToCamera = 0
this.charcter.isAttachedToMask = 0
this.charcter.layerDepth = 0
this.charcter.layerIndex = 0
this.charcter.maskLayerName = 0
this.timeline.addTween(cjs.Tween.get(this.charcter).wait(1));
}).prototype = p = new cjs.MovieClip();
p.nominalBounds = new cjs.Rectangle(778,539,-20,74);
// library properties:
lib.properties = {
id: '7249A8F452092C418E560C9BF70C0C94',
width: 1024,
height: 768,
fps: 30,
color: "#FFFFFF",
opacity: 1.00,
manifest: [
{src:"images/sample_atlas_.png", id:"sample_atlas_"}
],
preloads: []
};
// bootstrap callback support:
(lib.Stage = function(canvas) {
createjs.Stage.call(this, canvas);
}).prototype = p = new createjs.Stage();
p.setAutoPlay = function(autoPlay) {
this.tickEnabled = autoPlay;
}
p.play = function() { this.tickEnabled = true; this.getChildAt(0).gotoAndPlay(this.getTimelinePosition()) }
p.stop = function(ms) { if(ms) this.seek(ms); this.tickEnabled = false; }
p.seek = function(ms) { this.tickEnabled = true; this.getChildAt(0).gotoAndStop(lib.properties.fps * ms / 1000); }
p.getDuration = function() { return this.getChildAt(0).totalFrames / lib.properties.fps * 1000; }
p.getTimelinePosition = function() { return this.getChildAt(0).currentFrame / lib.properties.fps * 1000; }
an.bootcompsLoaded = an.bootcompsLoaded || [];
if(!an.bootstrapListeners) {
an.bootstrapListeners=[];
}
an.bootstrapCallback=function(fnCallback) {
an.bootstrapListeners.push(fnCallback);
if(an.bootcompsLoaded.length > 0) {
for(var i=0; i<an.bootcompsLoaded.length; ++i) {
fnCallback(an.bootcompsLoaded[i]);
}
}
};
an.compositions = an.compositions || {};
an.compositions['7249A8F452092C418E560C9BF70C0C94'] = {
getStage: function() { return exportRoot.getStage(); },
getLibrary: function() { return lib; },
getSpriteSheet: function() { return ss; },
getImages: function() { return img; }
};
an.compositionLoaded = function(id) {
an.bootcompsLoaded.push(id);
for(var j=0; j<an.bootstrapListeners.length; j++) {
an.bootstrapListeners[j](id);
}
}
an.getComposition = function(id) {
return an.compositions[id];
}
// Layer depth API :
AdobeAn.Layer = new function() {
this.getLayerZDepth = function(timeline, layerName)
{
if(layerName === "Camera")
layerName = "___camera___instance";
var script = "if(timeline." + layerName + ") timeline." + layerName + ".depth; else 0;";
return eval(script);
}
this.setLayerZDepth = function(timeline, layerName, zDepth)
{
const MAX_zDepth = 10000;
const MIN_zDepth = -5000;
if(zDepth > MAX_zDepth)
zDepth = MAX_zDepth;
else if(zDepth < MIN_zDepth)
zDepth = MIN_zDepth;
if(layerName === "Camera")
layerName = "___camera___instance";
var script = "if(timeline." + layerName + ") timeline." + layerName + ".depth = " + zDepth + ";";
eval(script);
}
this.removeLayer = function(timeline, layerName)
{
if(layerName === "Camera")
layerName = "___camera___instance";
var script = "if(timeline." + layerName + ") timeline.removeChild(timeline." + layerName + ");";
eval(script);
}
this.addNewLayer = function(timeline, layerName, zDepth)
{
if(layerName === "Camera")
layerName = "___camera___instance";
zDepth = typeof zDepth !== 'undefined' ? zDepth : 0;
var layer = new createjs.MovieClip();
layer.name = layerName;
layer.depth = zDepth;
layer.layerIndex = 0;
timeline.addChild(layer);
}
}
})(createjs = createjs||{}, AdobeAn = AdobeAn||{});
var createjs, AdobeAn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment