PIXI Controls: Idle animation
This commit is contained in:
parent
2a7101bd19
commit
62ab284977
1 changed files with 39 additions and 10 deletions
|
@ -32,6 +32,13 @@ ONSControls.createCanvas = function() {
|
|||
canvas.view.style.right = 0;
|
||||
canvas.view.style.down = 0;
|
||||
canvas.view.style.top = 0;
|
||||
canvas.stage.interactive = true;
|
||||
var idleInterval = setInterval(ONSControls.playIdleAnimation, 60000);
|
||||
canvas.stage.on("pointerdown", () => {
|
||||
this.stopIdleAnimation();
|
||||
clearInterval(idleInterval);
|
||||
idleInterval = setInterval(ONSControls.playIdleAnimation, 60000);
|
||||
})
|
||||
canvas.vh = (persent) => {
|
||||
return canvas.screen.height * persent;
|
||||
}
|
||||
|
@ -123,17 +130,40 @@ ONSControls.createAdditionalButtons = function() {
|
|||
// this.SwitchButton = switchButton;
|
||||
}
|
||||
//=============================================================================
|
||||
// * Idle animation (spinning buttons)
|
||||
// * Check idle animation (spinning buttons)
|
||||
//=============================================================================
|
||||
ONSControls.idleAnimation = function() {
|
||||
ONSControls.ButtonsContainer.rotation -= 0.1;
|
||||
ONSControls.DPadContainer.rotation += 0.1;
|
||||
ONSControls.LBsprite.rotation += 0.1;
|
||||
ONSControls.RBsprite.rotation -= 0.1;
|
||||
ONSControls.ShowButton.rotation += 0.1;
|
||||
//ONSControls.SwitchButton.rotation -= 0.1;
|
||||
}
|
||||
//=============================================================================
|
||||
// * Check idle animation (spinning buttons)
|
||||
//=============================================================================
|
||||
ONSControls.isIdlePlaying = false;
|
||||
//=============================================================================
|
||||
// * Play idle animation (spinning buttons)
|
||||
//=============================================================================
|
||||
ONSControls.playIdleAnimation = function() {
|
||||
this.controlsCanvas.ticker.add((delta) =>{
|
||||
this.ButtonsContainer.rotation -= 0.1 * delta;
|
||||
this.DPadContainer.rotation += 0.1 * delta;
|
||||
this.LBcontainer.rotation += 0.1 * delta;
|
||||
this.RBcontainer.rotation -= 0.1 * delta;
|
||||
this.ShowButton.rotation += 0.1 * delta;
|
||||
this.SwitchButton.rotation -= 0.1 * delta;
|
||||
});
|
||||
if (!ONSControls.isIdlePlaying) {
|
||||
ONSControls.isIdlePlaying = true;
|
||||
ONSControls.controlsCanvas.ticker.add(ONSControls.idleAnimation);
|
||||
}
|
||||
}
|
||||
//=============================================================================
|
||||
// * Stop idle animation (spinning buttons)
|
||||
//=============================================================================
|
||||
ONSControls.stopIdleAnimation = function() {
|
||||
ONSControls.controlsCanvas.ticker.remove(ONSControls.idleAnimation);
|
||||
ONSControls.ButtonsContainer.rotation = 0;
|
||||
ONSControls.DPadContainer.rotation = 0;
|
||||
ONSControls.LBsprite.rotation = 0;
|
||||
ONSControls.RBsprite.rotation = 0;
|
||||
ONSControls.ShowButton.rotation = 0;
|
||||
//ONSControls.SwitchButton.rotation = 0;
|
||||
}
|
||||
//=============================================================================
|
||||
// * Send event to virtual controller
|
||||
|
@ -531,6 +561,5 @@ ONSControls.initialize = function() {
|
|||
this.createBumpers();
|
||||
this.createAdditionalButtons();
|
||||
this.updateButtons();
|
||||
//this.playIdleAnimation();
|
||||
VirtualGamepad.connect();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue