123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- document.body.addEventListener('touchmove',bodyScroll,{passive: false});
- function bodyScroll(event){
- event.preventDefault();
- }
- var canvas = document.getElementById("canvas");
- var stage = new createjs.Stage(canvas);
- function init() {
- var comp = AdobeAn.getComposition("5529E26743974F469545223C44E61D22");
- var lib = comp.getLibrary();
- var loader = new createjs.LoadQueue(false);
- loader.addEventListener("fileload", function(evt) { handleFileLoad(evt, comp) });
- loader.addEventListener("complete", function(evt) { handleComplete(evt, comp) });
- loader.addEventListener("progress",loadProgressHandler);
- var lib = comp.getLibrary();
- loader.loadManifest(lib.properties.manifest);
- createjs.MotionGuidePlugin.install();
- }
- function handleFileLoad(evt, comp) {
- var loadingimages = comp.getImages();
- if (evt && (evt.item.type == "image")) {
- loadingimages[evt.item.id] = evt.result;
- }
- }
- function loadProgressHandler(event)
- {
- var num = Math.floor(event.progress*100);
- $("#loadingTxt").text(num);
- $("#loadingBar").css("width",num+'%');
- }
- function handleComplete(evt, comp) {
- //This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
- var lib = comp.getLibrary();
- var ss = comp.getSpriteSheet();
- var queue = evt.target;
- var ssMetadata = lib.ssMetadata;
- for (i = 0; i < ssMetadata.length; i++) {
- ss[ssMetadata[i].name] = new createjs.SpriteSheet({ "images": [queue.getResult(ssMetadata[i].name)], "frames": ssMetadata[i].frames })
- }
- var exportRoot = new lib.assets();
- $(".loading").fadeOut();
- $(".select-dish-box .item").on("click",function(){
- $(this).addClass("active").siblings().removeClass("active");
- $(".select-dish-box .confirm").show();
- })
- $(".select-dish-box .confirm").on("click",function(){
- if(!$(".select-dish-box .item").hasClass("active")){
- alert("请选择你要做的菜")
- return false;
- }
- $(".select-dish-box").hide();
- $(".game-box").show();
- })
- function bowlAnim(callback){
- var anim = new TimelineMax({onComplete:callback});
- anim.to(exportRoot.plate,0.5,{y:"-=370", ease:Power0.easeIn})
- anim.to(exportRoot.bowl,0.5,{alpha:1, ease:Power0.easeIn});
- return anim;
- }
- function proAnim(callback){
- var anim = new TimelineMax({onComplete:callback});
- anim.to(exportRoot.pro,0.3,{rotation:"-=20", ease:Power0.easeIn})
- anim.to(exportRoot.pro,1,{})
- anim.to(exportRoot.pro,0.3,{alpha:0, ease:Power0.easeIn})
- anim.to(exportRoot.pro,1,{})
- return anim;
- }
- exportRoot.plate.addEventListener("mousedown",function(){
- exportRoot.plate.removeAllEventListeners();
- exportRoot.plate.hsr_icon1.gotoAndStop(1);
- exportRoot.plate.hsr_icon2.gotoAndStop(1);
- exportRoot.plate.hsr_icon3.gotoAndStop(1);
- exportRoot.plate.hsr_icon4.gotoAndStop(1);
- bowlAnim(function(){
- exportRoot.plate.hsr_icon1.addEventListener("mousedown",function(){
- exportRoot.plate.hsr_icon1.removeAllEventListeners();
- exportRoot.plate.hsr_icon1.y = 600;
- })
- exportRoot.plate.hsr_icon2.addEventListener("mousedown",function(){
- exportRoot.plate.hsr_icon2.removeAllEventListeners();
- exportRoot.plate.hsr_icon2.y = 600;
- })
- exportRoot.plate.hsr_icon3.addEventListener("mousedown",function(){
- exportRoot.plate.hsr_icon3.removeAllEventListeners();
- exportRoot.plate.hsr_icon3.y = 650;
- })
- exportRoot.plate.hsr_icon4.addEventListener("mousedown",function(){
- exportRoot.plate.hsr_icon4.removeAllEventListeners();
- exportRoot.plate.hsr_icon4.y = 600;
- })
- exportRoot.btn1.alpha = 1;
- exportRoot.btn1.addEventListener("mousedown",function(){
- exportRoot.btn1.removeAllEventListeners();
- exportRoot.btn1.alpha = 0;
- exportRoot.plate.alpha = 0;
- exportRoot.bowl.alpha = 0;
- exportRoot.pot.alpha = 1;
- exportRoot.pro.alpha = 1;
- proAnim(function(){
- exportRoot.pot.hsr.alpha = 1;
- exportRoot.btn2.alpha = 1;
- });
- })
- exportRoot.btn2.addEventListener("mousedown",function(){
- exportRoot.btn2.removeAllEventListeners();
- exportRoot.btn2.alpha = 0;
- exportRoot.blackboard.alpha = 1;
- exportRoot.ball1.alpha = 1;
- })
- });
- })
- //Registers the "tick" event listener.
- function fnStartAnimation() {
- stage.addChild(exportRoot);
- createjs.Ticker.timingMode = createjs.Ticker.RAF_SYNCHED;
- createjs.Ticker.addEventListener("tick", stage);
- }
- fnStartAnimation();
- stageBreakHandler();
- }
- // 自适应
- var stageWidth, stageHeight, stageScale;
- function stageBreakHandler(event) {
- if (stageWidth != $(".warp").width() || stageHeight != $(".warp").height()) {
- stageWidth = $(".warp").width();
- stageHeight = $(".warp").height();
- stageScale = stageWidth / 640;
- canvas.style.width = 640 * stageScale + 'px';
- canvas.style.height = 1040 * stageScale + 'px';
- }
- }
|