var EHDI = EHDI || Object.create(null); EHDI.loadScene = function setupLoader() { var loaderContainer = new PIXI.Container(); var proximanova = new EHDI.aka.PixiText("hello world", {fontFamily: 'proximanova-black'}); var exo = new EHDI.aka.PixiText("", {fontFamily: 'Exo-Bold'}); loaderContainer.addChild(proximanova); loaderContainer.addChild(exo); /* window.addEventListener('screenDidAppear', function() { console.log("screen is now visible"); }); window.addEventListener('screenDidDisappear', destroy);*/ //load config //initialize the json files to be managed var bg = new PIXI.extras.TilingSprite(EHDI.Assets.images["gfx_bg"], EHDI.GAME.sceneManager.getStageWidth(), EHDI.GAME.sceneManager.getStageHeight()); //var bg = new EHDI.displays.FillRectangle(0xFF7874, 0, 0, EHDI.GAME.sceneManager.getStageWidth(), EHDI.GAME.sceneManager.getStageHeight()); loaderContainer.addChild(bg); var loadingBorder = new EHDI.aka.Sprite(EHDI.Assets.images["gfx_loading"]); loadingBorder.anchor.x = 0.5; loadingBorder.anchor.y = 0.5; loadingBorder.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.5); loaderContainer.addChild(loadingBorder); var loadingBarBorder = new EHDI.aka.Sprite(EHDI.Assets.images["gfx_loading_bar_con"]); loadingBarBorder.anchor.set(0.5, 0.5); loadingBarBorder.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.64); loaderContainer.addChild(loadingBarBorder); var loadingText = new EHDI.aka.PixiText("LOADING...", {fontFamily: 'proximanova-black', fill: 0xFFFFFF, fontSize : 16}); loadingText.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.316, EHDI.GAME.sceneManager.getStageHeight() * 0.595); loaderContainer.addChild(loadingText); var loadingContainer = new EHDI.displays.FillRectangle(0x000000, 0, 0, 380, 27); loadingContainer.anchor.x = 0.5; loadingContainer.anchor.y = 0.5; loadingContainer.position.x = EHDI.GAME.sceneManager.getStageWidth() * 0.5; loadingContainer.position.y = EHDI.GAME.sceneManager.getStageHeight() * 0.65; loaderContainer.addChild(loadingContainer); var loadingBar = new EHDI.displays.FillRectangle(0x1999F1, 0, 0, 380, 27); loadingContainer.addChild(loadingBar); loadingBar.x = -loadingContainer.width * 0.5; loadingBar.y = -loadingContainer.height * 0.5; var loadingWidth = loadingBar.width; var tapAnywhere = null; var tapAnywhereTimeline = null; EHDI.LoadManager.queueStrings(EHDI.gameStringsToLoad); EHDI.LoadManager.queueAssets(EHDI.assetsToLoad); EHDI.LoadManager.start(startGame); EHDI.GAME.updateManager.addFrameListener(update); var dbFactory = new dragonBones.PixiFactory(); var textureImage = EHDI.Assets.images["gizmoloading_tex"].baseTexture.source; var textureData = EHDI.Assets.fetch("gizmoloading_tex"); dbFactory.addTextureAtlas(new dragonBones.TextureAtlas(textureImage, textureData)); var skeleton = EHDI.Assets.fetch("gizmoloading_ske"); dbFactory.addDragonBonesData(dragonBones.DataParser.parseDragonBonesData(skeleton)); var armature = dbFactory.buildArmature(skeleton.armature[0].name); dragonBones.WorldClock.clock.add(armature); armature.animation.gotoAndPlay(armature.animation.animationList[0], -1, -1, 0); armature.animation.play(); var animationSprite = armature.getDisplay();; animationSprite.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.55); loaderContainer.addChild(animationSprite); EHDI.GAME.updateManager.addFrameListener(updateAnimationClock); function updateAnimationClock(dt) { dragonBones.WorldClock.clock.advanceTime(dt * 0.001); } function update() { //console.log(EHDI.GAME.loader.getProgress()); loadingBar.scale.x = EHDI.LoadManager.getProgress() / 100; }; function startGame() { loadingBar.scale.x = EHDI.LoadManager.getProgress() / 100; EHDI.GAME.updateManager.removeFrameListener(update); if(EHDI.BrowserInfo.isIOS) { tapAnywhere = new EHDI.aka.PixiText("TAP ANYWHERE TO CONTINUE", {fontFamily: 'proximanova-black', fill: 0xFFFFFF, fontSize : 26}); tapAnywhere.anchor.set(0.5, 0.5); tapAnywhere.position.set(EHDI.GAME.sceneManager.getStageWidth() * 0.5, EHDI.GAME.sceneManager.getStageHeight() * 0.65); loaderContainer.addChild(tapAnywhere); tapAnywhere.alpha = 0; tapAnywhereTimeline = new TimelineMax(); tapAnywhereTimeline.to(loadingText, 0.25, {alpha : 0}, 0); tapAnywhereTimeline.to(loadingContainer, 0.25, {alpha : 0}, 0); tapAnywhereTimeline.to(tapAnywhere, 0.25, {alpha : 1}, 0); tapAnywhereTimeline.add(function() { bg.interactive = true; tapAnywhereTimeline.kill(); tapAnywhereTimeline = new TimelineMax({repeat : -1, repeatDelay : 1, delay : 1}); tapAnywhereTimeline.to(tapAnywhere, 1, {alpha : 0}); tapAnywhereTimeline.to(tapAnywhere, 0.5, {alpha : 1}, "+=0.2"); }); bg.touchstart = function() { bg.interactive = false; EHDI.GAME.soundManager.playSFX("button_sfx"); EHDI.GAME.sceneManager.changeScene(new EHDI.scene.TitleScene(), {alpha : new EHDI.scene.TransitionParameter(0,1), duration : 1}); } } else { setTimeout(function(){ EHDI.GAME.sceneManager.changeScene(new EHDI.scene.TitleScene(), {alpha : new EHDI.scene.TransitionParameter(0,1), duration : 1}) }, 500); } /*playGameBtn = new EHDI.displays.Button(EHDI.Assets.images["btn_play"], EHDI.Assets.images["btn_play2"], null, null); playGameBtn.setOnClickFunction(function(){ EHDI.GAME.soundManager.playSFX("button_sfx"); EHDI.GAME.sceneManager.changeScene(new EHDI.scene.TitleScene(), {alpha : new EHDI.scene.TransitionParameter(0,1), duration : 1}) }); playTxt = new EHDI.aka.PixiText("PLAY", {fontFamily: 'proximanova-black', fill: 0xFFFFFF, fontSize : 32}); playTxt.anchor.set(0.75, 0.5); playGameBtn.addChild(playTxt); loaderContainer.addChild(playGameBtn); playGameBtn.x = EHDI.GAME.sceneManager.getStageWidth() * 0.5; playGameBtn.y = EHDI.GAME.sceneManager.getStageHeight() * 0.85;*/ }; loaderContainer.screenDidDisappear = function(){ //destroy EHDI.GAME.updateManager.removeFrameListener(updateAnimationClock); dbFactory.dispose(); dragonBones.WorldClock.clock.remove(armature); armature.dispose(); loaderContainer.destroy({children : true}); //window.removeEventListener('screenDidDisappear', destroy); } EHDI.GAME.sceneManager.changeScene(loaderContainer); }