Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- http://youtube.com/LegitzDestroy asked for a way to memorize the concepts. In my opinion, a good way to do this is to remember the order of things you have to do to create a new Screen from scratch.
- Short summary:
- 1: create class that implements Screen 00:58
- 2: create fields that you'll need: Stage, Skin 01:25
- 3: make sure to dispose everything in dispose() 04:38
- 4: make sure dispose() is called by putting it in hide() 05:43
- 5: clear the screen, update and render the stage in render() 06:14
- 6: resize the stage and optionally other things in resize() 07:39
- 5: set them in the show() method, basically create the menu there 09:45
- 5.1: stage = new Stage();
- 5.2: don't forget Gdx.input.setInputProcessor(stage);
- 5.2: skin = new Skin(Gdx.files.internal("ui/skinFile.json"), new TextureAtlas("ui/atlas.pack"));
- 5.3: create all the Actors you want
- 5.4: put actors in each other (e.g. buttons in table, table in stage)
- 5.5: put actors in the stage
- Or like this:
- --------------------
- public class Concepts implements Screen {
- // 1. setup variables
- private Stage stage;
- private Skin skin;
- // 2. create objects
- @Override
- public void show() {
- stage = new Stage();
- skin = new Skin(Gdx.files.internal("ui/creditsSkin.json"), new TextureAtlas("ui/atlas.pack"));
- }
- // 3. dispose stuff
- @Override
- public void dispose() {
- stage.dispose();
- skin.dispose();
- }
- // 4. actually dispose
- @Override
- public void hide() {
- dispose();
- }
- // 5. render
- @Override
- public void render(float delta) {
- // 5.1 clear screen
- Gdx.gl.glClearColor(0, 0, 0, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- // 5.2 update
- stage.act(delta);
- // 5.3 draw
- stage.draw();
- }
- // 6. resize if needed
- @Override
- public void resize(int width, int height) {
- stage.setViewport(width, height, false);
- }
- @Override
- public void pause() {
- }
- @Override
- public void resume() {
- }
- }
- --------------------
- Concept for the TweenEngine:
- 1. write Accessors (implementing TweenAccessor<Class>):
- - make a switch statement that takes tweenType
- - set returnValues to values of target / set attributes of target with newValues
- 2. create a TweenManager
- - tweenManger = new TweenManager(); // as simple as that
- - update it in render method: tweenManager.update(delta); // simple again
- 3. register TweenAccessors:
- - e.g. Tween.registerAccessor(Actor.class, new ActorAccessor());
- 4. create animations:
- - Tween.to(buttonPlay, ActorAccessor.ALPHA, 2).target(1).start(tweenManager); // alpha transparency goes to 1 in 2 seconds
- - Tween.from(buttonPlay, ActorAccessor.ALPHA, 2).target(0)).start(tweenManager); // alpha transpareny comes from 0 to what is has been before in 2 seconds
- 5. you can create Timelines:
- - Timeline.create[Sequence/Parallel]().begin[Sequence/Parallel]().push(animation).push(infinite_more_animations).end().start(tweenManager);
- --------------------
- Sorry for no uploads in a long time. If you want to know about the current progress, you can have a look at https://trello.com/b/Y3az2rtU/development.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement