//=============================================================================
// Version: 1.00
// License: A new fantastic time the orbs quests
//=============================================================================
/*:
* @plugindesc $system.BOOT._IntroScreen
* @author Jonathan Lepage
* @help
*/
// ┌□COLORIMETRIX□───────────────────────────────────────-REFERENCE-─────────────────────────────────────────────────────────────────────────┐
//#d8a757, #f46e42, #f4eb41, #b241f4, #f44197, #f4415e, #b71f37, #b71e1e, #b7af1d, #f28a0c, #aed0f9, #dd2b01, #eb0e4b, #c37665, #a74313, #c5e264,
//#cc9b99, #c85109, #fedcb4, #a36506, #a0ff0c, #a000d0, #a00000, #ADB6BE, #B24387 ,#BBC15D ,#FA8965 ,#F3EE1E ,#CC301D
// └──────────────────────────────────────────────────────□□□□□□□□□──────────────────────────────────────────────────────────────────────────┘
//############################### HUDS CONSTRUCTOR #####################################//
function _IntroScreen() {
this.initialize.apply(this, arguments);
};
_IntroScreen.prototype.initialize = function(newPID) {
this._isEventName = 'introscreen'; // permet de voir la derniere en cour $system._sceneActivity[], pour la gestion des clicks
this._isPreload = false; // WHEN CLEAR ALL, THIS SET TO FALSE
this._position = null; // DEFINE CURRENT POSITION FOR EVALUATION ?
//################### BASE ELEMENT ID ##############################################//
this._PID = newPID; // set the start picture id (global Menue)
this._PID_end = null; // set the end picture id (global Menue)
this.pidElement = null; // ou commence les picture element
//################### TIMER EASING CONTROL #########################################//
this.clearTimer = new IAVRA.ANIMATE.Tween(null,{},1); // for clear
this.timer1 = new IAVRA.ANIMATE.Tween(null,{},1); // for clear
//################### LOADER PIXI ##################################################//
this.vidLoader = new PIXI.loaders.Loader(); // loader for video
this.spriteAniLoader = new PIXI.loaders.Loader(); // loader for sprite animation
//################### CUSTOMS VARIABLES ############################################//
this.videoTexture = {};
this.vidControl = {};
this.videoSprite = {};
this.CheckMouseMove = {}; // check tmp mouse move
//################## STRING PICTURES FILES NAMES ###################################//
this.pFN = [ // picture Files Names
];
//################### PRESET PIXI TXTSTYLE #########################################//
//SINGLE
var globalStyle = $system.pixiStyle.standar;
this.txtStyle = [
{fontSize: 30,strokeThickness: 6,align: 'right',fontWeight:'bold',letterSpacing: 3},];
//MULTISTYLE STYLE PIXI TEXT
this.txtMultiStyle = [{
"primary":{lineStyle:'top',lineHeight:-2,align:"right",},
"def": {strokeThickness: 12,fontSize: "64px",letterSpacing: -5,fontWeight:'bold',},
"s0": {fontSize: "32px",strokeThickness: 6,letterSpacing: -1,fontWeight:'bold',},
}];
// ADD TO ALL OBJ STYLE
for(var s=0,len=this.txtStyle.length;s<len;s++){ //txtStyle
this.txtStyle[s] = Object.assign({}, globalStyle, this.txtStyle[s]);
};
for(var s=0,len=this.txtMultiStyle.length;s<len;s++){ //txtMultiStyle
for (var tag in this.txtMultiStyle[s]) {
if(tag!=='primary'){
this.txtMultiStyle[s][tag] = Object.assign({}, globalStyle, this.txtMultiStyle[s][tag]);
}}};
};
//############################### HUDS CONSTRUCTOR #####################################//
//########################### PROTOTYPE FOR CONSTRUCTOR ################################//
// PROTOTYPE □─────────────────────────────────────────-PRELOAD_LOAD-────────────────────────────────────────────────────────────────┐
//¦ □ $system.BOOT._IntroScreen.preLoad()
//¦ □ .preLoad
// └─────────────────────────────────────────────────────□□□□□□□□□───────────────────────────────────────────────────────────────────┘
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.preLoad = function(firstBoot){
return; /// bypass intro
var pID = this._PID.valueOf();
var that = this;
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
var videoTexture = {}, vidControl = {}, videoSprite = {};
this.videoTexture = videoTexture, this.vidControl = vidControl, this.videoSprite = videoSprite;
// PRELOAD STEP1 VIDEO
this.vidLoader
.add('vIntro', 'video/intro/original_intro1.webm')
.add('vLooper', 'video/intro/original_intro1Loop.webm')
.add('vpreLogo1', 'video/intro/intro_logo.webm')
.load(); //↓↓↓ startLOAD list ↓↓↓
this.vidLoader.onLoad.add(function (loader, resource) { // add callback At eatch load element
console.log('loader.progress: ',pID, loader.progress);
videoTexture[resource.name] = PIXI.Texture.fromVideo(resource.url) //.autoPlay = false
vidControl[resource.name] = videoTexture[resource.name].baseTexture;
vidControl[resource.name].autoPlay = false;
vidControl[resource.name].pID = pID; // store pid controle
videoSprite[resource.name] = new PIXI.Sprite(videoTexture[resource.name]);
$gameScreen.showPicture(pID++, '', 0, 0, 0,'','',0).addChild(videoSprite[resource.name]); //#d8a757 VIDEO CONTAINERS {0 opacity}
});
//finish load sprite
this.vidLoader.onComplete.add(function (loader, resource) { // poload step2 =>
// □ animation:(fN, or, x, y, sX, sY, op, bM, frame, line, _delay) □ basic:(fN, or, x, y, sX, sY, op, bM).setAngle().setRot().bindToMap()
that.pidElement = pID;
$gameScreen.showPictureAni(pID++, "Global/Misc/logo_intro", 1,(900),(320),50,100,0,0,4,1,70); //#b241f4 LOGO ANI
$gameScreen.showPictureAni(pID++, "Global/Misc/ts_backMenu", [1,0.5],(1800),(636),0,100,150,0,4,1,85); //#f44197 BACKGROUND MENUE ANI
$gameScreen.setPictureTrigger(pID-1, "Mouse Over", function(pid){ that.hoverTITLEBackG(pid); });
$gameScreen.setPictureTrigger(pID-1, "Mouse Out", function(pid){ that.hoverOutTITLEBackG(pid); });
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, "Global/Misc/ts_NG", 1,(1685),(500),65,100,255,0,8,2,70); //#f4415e TITLE NEWGAME ANI
$gameScreen.setPictureTrigger(pID-1, "Mouse Over", function(pid){ that.hoverTITLE(pid); });
$gameScreen.setPictureTrigger(pID-1, "Mouse Out", function(pid){ that.hoverOutTITLE(pid); });
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, "Global/Misc/ts_LG", 1,(1685),(600),65,100,255,0,8,2,70); //#b71f37 TITLE LOAD GAME ANI
$gameScreen.setPictureTrigger(pID-1, "Mouse Over", function(pid){ that.hoverTITLE(pid); });
$gameScreen.setPictureTrigger(pID-1, "Mouse Out", function(pid){ that.hoverOutTITLE(pid); });
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, "Global/Misc/ts_OP", 1,(1685),(700),65,100,255,0,8,2,70); //#b71e1e TITLE OPTIONS ANI
$gameScreen.setPictureTrigger(pID-1, "Mouse Over", function(pid){ that.hoverTITLE(pid); });
$gameScreen.setPictureTrigger(pID-1, "Mouse Out", function(pid){ that.hoverOutTITLE(pid); });
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, "Global/Misc/ts_CR", 1,(1685),(800),65,100,255,0,8,2,70); //#b7af1d TITLE CREDITS ANI
$gameScreen.setPictureTrigger(pID-1, "Mouse Over", function(pid){ that.hoverTITLE(pid); });
$gameScreen.setPictureTrigger(pID-1, "Mouse Out", function(pid){ that.hoverOutTITLE(pid); });
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, 'avatar/intro_run_Ava1', 1,-50,783,22,22,255,0,16,1,52); //#f28a0c AVATAR1
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
$gameScreen.showPictureAni(pID++, 'avatar/intro_run_Ava2', 1,-55,733,35,35,255,0,13,1,45); //#aed0f9 AVATAR2
$gameScreen.picture(pID-1).startPictureAnimation("infinite");
that.timer1.stop().dur(100).start().onComplete(function(){ that.startIntro1() }); // jumpshorcut Fix startIntro1 ()
});
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
// PROTOTYPE □──────────────────────────────────────────-START_INTRO-────────────────────────────────────────────────────────────────┐
//¦ □ $system.BOOT._IntroScreen.preLoad()
// └─────────────────────────────────────────────────────□□□□□□□□□───────────────────────────────────────────────────────────────────┘
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.startIntro1 = function(){
var that = this;
var vidControl = this.vidControl.vpreLogo1;
$gameScreen._pictures[vidControl.pID]._opacity = 255; // affiche limage qui contien video
vidControl.source.onended = function(){ $gameScreen.erasePicture(vidControl.pID); that.startIntro2(); } // jouer autre module startIntro2
vidControl.source.play();
}
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.startIntro2 = function(){
var that = this;
var pidE = this.pidElement;
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
var introAudio = { name: 'intro1', volume: 100, pitch: 100, pan: 0 }; // audio intro1
var vidControl = this.vidControl.vIntro;
$gameScreen._pictures[vidControl.pID]._opacity = 255; // affiche limage qui contien video
vidControl.source.onplay = function(){ AudioManager.playBgm(introAudio); }; // when play video play audio
vidControl.source.addEventListener("timeupdate", function test() { // do something at X time video {alpha text show}
console.log('this.currentTime: ', this.currentTime);
if (this.currentTime > 18.6) {
console.log('MOVEEEE ALLL');
$m1[pidE].Move({_opacity:255,_scaleX:100,_scaleY:100}).ease(IAVRA.EASING.elastic.out).dur(100).start();//#b241f4 LOGO ANI
$gameScreen.picture(pidE).startPictureAnimation("infinite");
$m1[pidE+1].Move({_x:1600,_scaleX:100}).ease(IAVRA.EASING.exp.out).dur(100).start();//#f44197 BACKGROUND MENUE ANI
$m1[pidE+2].preAn(30).Move({_x:1465,_scaleX:100,_angle:0}).ease(IAVRA.EASING.elastic.out).dur(120).start();//#f4415e TITLE NEWGAME ANI
$m1[pidE+3].preAn(-30).Move({_x:1465,_scaleX:100,_angle:0}).ease(IAVRA.EASING.elastic.out).dur(120).start();//#b71f37 TITLE LOAD GAME ANI
$m1[pidE+4].preAn(30).Move({_x:1465,_scaleX:100,_angle:0}).ease(IAVRA.EASING.elastic.out).dur(120).start();//#b71e1e TITLE OPTIONS ANI
$m1[pidE+5].preAn(30).Move({_x:1465,_scaleX:100,_angle:0}).ease(IAVRA.EASING.elastic.out).dur(120).start();//#b7af1d TITLE CREDITS ANI
$m1[pidE+6].preAn(-120).Move({_x:1122,_angle:0}).ease(IAVRA.EASING.back.out).dur(120).start();//#f28a0c AVATAR1
var starMouseFollow = function(){
// add mouse listener
window.addEventListener("mousemove", function checkMouseTMP() {
var x = Graphics.pageToCanvasX(event.pageX), y = Graphics.pageToCanvasY(event.pageY);
x = ((x>1255)&&1255%x||x);
$m1[that.pidElement+7].Move({_x:x,_y:y}).ease(IAVRA.EASING.quad.out).dur((x===1255)&&50||30).start();
}, false);
};
$m1[pidE+7].preAn(800).Move({_x:1039,_angle:0}).ease(IAVRA.EASING.back.out).dur(140).start().onComplete(starMouseFollow);//#aed0f9 AVATAR2
this.removeEventListener('timeupdate',test);// TODO:
}
}, false);
vidControl.source.onended = function(){ $gameScreen.erasePicture(vidControl.pID); that.startLoop();} // jouer autre module LOOP
vidControl.source.play(); //PLAY
}
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.startLoop = function(){
//TEST PROJECTION***********_____________
/*
var vidControl = this.vidControl.vLooper;
var squareX = new PIXI.Sprite(PIXI.Texture.WHITE);
squareX.tint = 0xff0000;
squareX.factor = 0.1;
squareX.anchor.set(0.5);
squareX.position.set(1600*2, 486);
var squareY = new PIXI.Sprite(PIXI.Texture.WHITE);
squareY.tint = 0xff0000;
squareY.factor = 0;
squareY.anchor.set(0.5);
squareY.position.set(1600/2,900+(900/2));
// create a new Sprite from an image path
var container = new PIXI.projection.Container2d();
container.position.set(1600/2, 900/2);
//add sprite itself
var bunny = new PIXI.projection.Sprite2d(new PIXI.Texture.fromImage('video/intro/testOverlap.png'));
//////
var tggsrg = new PIXI.projection.Sprite2d(new PIXI.Texture.fromImage('video/intro/bggrassTest.webm'));
bunny.alpha = 0.5;
tggsrg.position.set(0, 0);
//////
console.log('bunny: ', bunny);
bunny.anchor.set(0,0.5);
bunny.scale.set(-1,1);
bunny.position.set(700, 0);
container.addChild(bunny);
container.addChild(tggsrg);
SceneManager._scene._spriteset._pictureContainer.children[(vidControl.pID)-1].addChild(container);
SceneManager._scene._spriteset._pictureContainer.children[(vidControl.pID)-1].addChild(squareX);
SceneManager._scene._spriteset._pictureContainer.children[(vidControl.pID)-1].addChild(squareY);
//illuminate the sprite from two points!
var lightY = new PIXI.projection.Sprite2d(PIXI.Texture.WHITE);
lightY.anchor.set(0.5, 0.1);
lightY.scale.set(15, 900);
lightY.alpha = 0.2;
container.addChildAt(lightY, 0);
var lightX = new PIXI.projection.Sprite2d(PIXI.Texture.WHITE);
lightX.anchor.set(0.1, 0.5);
lightX.scale.set(900, 15);
lightX.alpha = 0.2;
container.addChildAt(lightX, 1);
var testTikerLisent = new PIXI.ticker.Ticker;
testTikerLisent.add(function (delta) {
// clear the projection
container.proj.clear();
container.updateTransform();
if(TouchInput.x<500){
squareX.position._x = TouchInput.x;
bunny.x = 1000+(TouchInput.x/2);
}
bunny.y = -100+(TouchInput.y/10);
squareY.position.set((1600/2)+(TouchInput.x/10),900+(900/2)-bunny.y);
//squareX.position._y = TouchInput.y;
// now we can get local coords for points of perspective
var posX = container.toLocal(squareX.position);
var posY = container.toLocal(squareY.position);
container.proj.setAxisX(posX, squareX.factor);
container.proj.setAxisY(posY, squareY.factor);
});
testTikerLisent.start();
console.log('testTikerLisent: ', testTikerLisent);
*/
//TEST PROJECTION***********_____________
var that = this;
var vidControl = this.vidControl.vLooper;
vidControl.source.loop = true;
$gameScreen._pictures[vidControl.pID]._opacity = 255; // affiche limage qui contien video
vidControl.source.onended = function(){ $gameScreen.erasePicture(vidControl.pID); } // jouer autre module LOOP
vidControl.source.play(); //PLAY
}
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
// PROTOTYPE □────────────────────────────────────────-TRIGGER_CALLBACK-─────────────────────────────────────────────────────────────┐
//| □ $system.BOOT._IntroScreen.()
//| □ [clickedOnAvatart]
// └──────────────────────────────────────────────────────□□□□□□□□□──────────────────────────────────────────────────────────────────┘
//END FIREST VIDEO
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.playVideoTitle = function(){
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.hoverTITLE = function(pID){
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
$gameScreen._pictures[pID]._linePos = 1;
//$gameScreen.tintPicture(pID, [40,40,40,0], 10); //#f4eb41 newgame
$m1[pID].Move({_scaleX:110,_scaleY:110,_angle:2}).ease(IAVRA.EASING.elastic.out).dur(25).start();
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.hoverOutTITLE = function(pID){
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
$gameScreen._pictures[pID]._linePos = 0;
//$gameScreen.tintPicture(pID, [40,40,40,0], 10); //#f4eb41 newgame
$m1[pID].Move({_scaleX:100,_scaleY:100,_angle:0}).ease(IAVRA.EASING.elastic.out).dur(25).start();
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.hoverTITLEBackG = function(pID){
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
//$gameScreen.tintPicture(pID, [40,40,40,0], 10); //#f44197 BACKGROUND MENUE ANI
$m1[pID].Move({_opacity:200,_scaleX:110,_scaleY:110}).ease(IAVRA.EASING.quad.inOut).dur(10).start();//#f44197 BACKGROUND MENUE ANI
$m1[pID].Move({_opacity:200,_scaleX:110,_scaleY:110}).ease(IAVRA.EASING.quad.inOut).dur(10).start();//#f44197 BACKGROUND MENUE ANI
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.hoverOutTITLEBackG = function(pID){
var $m1 = $gameScreen._picturesEasing1; // ref to $gameScreen._picturesEasing1
$gameScreen._pictures[pID]._linePos = 0;
//$gameScreen.tintPicture(pID, [40,40,40,0], 10); //#f44197 BACKGROUND MENUE ANI
$m1[pID].Move({_opacity:150,_scaleX:100,_scaleY:100}).ease(IAVRA.EASING.quad.inOut).dur(10).start();//#f44197 BACKGROUND MENUE ANI
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
// PROTOTYPE □──────────────────────────────────────────-DELETE_CLOSE-────────────────────────────────────────────────────────────────┐
//» □ $system.BOOT._IntroScreen.clearAll()
//» □ [clearAll]
// └──────────────────────────────────────────────────────□□□□□□□□□□──────────────────────────────────────────────────────────────────┘
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.clearAll = function(){
var pID = this._PID.valueOf(), pID_end = this._PID_end+1;
for (;pID<pID_end;pID++){ $gameScreen.erasePicture(pID); };
this._isPreload = false;
console.log('%c'+this.constructor.name+' CLEARED',ccss[1],this._PID.valueOf(),pID_end-1);
};
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑
//□▼↓▼□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↓↓↓
_IntroScreen.prototype.clearTimeOut = function(timeOut){
// penser a ajouter un objet pour identifier le mode
var that = this;
var startClear = function(){
that.clearAll();
}
this.clearTimer.stop().dur(timeOut).start().onComplete(startClear); //⏳
}
//□▲↑▲□═══════════════════════════════════════════════════□□═══════════════════════════════════════════════════□↑↑↑