Created
October 30, 2020 15:15
-
-
Save Mr00Anderson/60e1bb006e988451dff0550889993697 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.virtual_hex.gdx.engine.scene2d.actions; | |
import com.badlogic.gdx.math.Interpolation; | |
import com.badlogic.gdx.utils.Array; | |
import com.virtual_hex.app.AppLauncher; | |
import com.virtual_hex.gdx.engine.Cleanup; | |
import com.virtual_hex.gdx.engine.app.GdxEngScreenManagerApp; | |
import com.virtual_hex.gdx.engine.assets.AnAsset; | |
import com.virtual_hex.gdx.engine.assets.AssetList; | |
import com.virtual_hex.gdx.engine.scene2d.EngStage; | |
import com.virtual_hex.gdx.engine.scene2d.VirtualHexSplashOneAssets; | |
import com.virtual_hex.gdx.engine.screens.GdxEngAppScreen; | |
import com.virtual_hex.gdx.engine.state.StateRefIntWrapper; | |
import java.util.HashMap; | |
public class ScreenPlayBuilder { | |
public Array<EngActorScreenPlayAsset> actors; | |
public AssetList assetList; | |
public int totalActors; | |
private transient StateRefIntWrapper volume; | |
// Make sure all are removed after | |
// Make sure we notify when complete | |
public ScreenPlayBuilder(Array<EngActorScreenPlayAsset> actors) { | |
this.actors = actors; | |
this.assetList = new AssetList(new HashMap<>(), new HashMap<>()); | |
this.totalActors = 0; | |
} | |
public AssetList buildAssetList(){ | |
int size = actors.size; | |
for (int i = 0; i < size; i++) { | |
EngActorScreenPlayAsset screenPlayAsset = actors.get(i); | |
screenPlayAsset.actorAsset.addAssets(assetList); | |
screenPlayAsset.actions.addAssets(assetList); | |
} | |
return assetList; | |
} | |
public <APP extends GdxEngScreenManagerApp> void setupAndStart(AppLauncher<APP> appLauncher, GdxEngAppScreen<APP> screen, EngStage stage, Cleanup cleanup, StateRefIntWrapper volume) { | |
this.volume = volume; | |
int size = actors.size; | |
for (int i = 0; i < size; i++) { | |
EngActorScreenPlayAsset playAsset = actors.get(i); | |
playAsset.build(appLauncher, screen, stage, cleanup, volume); | |
} | |
} | |
// Abstract away that we need to have a "screen play" so we can know when this whole one is finished | |
// and be ready for the new one | |
public static ScreenPlayBuilder getVirtualHexSplashOne(EngActorScreenPlayAsset appSpecific, String nextScreen) { | |
Array<EngActorScreenPlayAsset> actors = new Array<>(); | |
ScreenPlayBuilder screenPlay = new ScreenPlayBuilder(actors); | |
AnimationActorAsset animationActorAsset = | |
new AnimationActorAsset("bad_logic", "images/logo/libgdx/libGDX_BadLogic_Logo_angle", 0.10f, 64, 1); | |
ImageActorAsset imageActorAsset = new ImageActorAsset("vhex", VirtualHexSplashOneAssets.TEXTURE, 0); | |
LabelActorAsset labelActorAsset = new LabelActorAsset( | |
"Virtual Hex Games\n\n" + | |
"Powered by libGDX", 0); | |
EngAction lastAction; | |
if(appSpecific == null){ | |
lastAction = new EngScreenSetAction(nextScreen); | |
} else { | |
lastAction = new EngSequenceAction() | |
.add(new EngAddNewActorAction(appSpecific)) | |
.add(new EngRemoveActorAction()); | |
} | |
EngActorScreenPlayAsset labelAsset = new EngActorScreenPlayAsset(); | |
labelAsset.actorAsset = labelActorAsset; | |
labelAsset.actions = new EngSequenceAction() | |
.add(new EngSizeByAction(200, 200, 0, Interpolation.linear)) | |
.add(new EngAlphaAction(1)) | |
.add(new EngPlaySoundAction(new AnAsset("splishSplosh", VirtualHexSplashOneAssets.SMASH_SPLOSH))) | |
.add(new EngDelayAction(3)) | |
.add(new EngFadeOutAction(3)) | |
.add(lastAction) | |
.add(new EngRemoveActorAction()); | |
EngActorScreenPlayAsset badLogicAnimation = new EngActorScreenPlayAsset(); | |
badLogicAnimation.actorAsset = animationActorAsset; | |
badLogicAnimation.actions = new EngSequenceAction() | |
.add(new EngDelayAction(7)) | |
.add(new EngAddNewActorAction(labelAsset)) | |
.add(new EngRemoveActorAction()); | |
EngActorScreenPlayAsset engActorAsset = new EngActorScreenPlayAsset(); | |
engActorAsset.actorAsset = imageActorAsset; | |
engActorAsset.actions = new EngSequenceAction() | |
.add(new EngDelayAction(1)) | |
.add(new EngPlaySoundAction(new AnAsset("electric", VirtualHexSplashOneAssets.SOUND_INTRO_1_ELECTRIC), .5f)) | |
.add(new EngFadeInAction(5, Interpolation.bounce)) | |
.add(new EngDelayAction(1)) | |
.add(new EngPlaySoundAction(new AnAsset("ping",VirtualHexSplashOneAssets.SOUND_INTRO_2_PING_OUT))) | |
.add(new EngFadeOutAction(2)) | |
.add(new EngAddNewActorAction(badLogicAnimation)) | |
.add(new EngRemoveActorAction()); | |
// .add(new EngScreenSetAction("main")); | |
actors.add(engActorAsset); | |
return screenPlay; | |
} | |
public interface CompleteListener { | |
void completedSequence(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment