• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*******************************************************************************
2  * Copyright 2011 See AUTHORS file.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  ******************************************************************************/
16 
17 package com.badlogic.gdx.tests;
18 
19 import static com.badlogic.gdx.scenes.scene2d.actions.Actions.fadeIn;
20 import static com.badlogic.gdx.scenes.scene2d.actions.Actions.fadeOut;
21 import static com.badlogic.gdx.scenes.scene2d.actions.Actions.forever;
22 import static com.badlogic.gdx.scenes.scene2d.actions.Actions.sequence;
23 
24 import com.badlogic.gdx.Gdx;
25 import com.badlogic.gdx.graphics.GL20;
26 import com.badlogic.gdx.graphics.Texture;
27 import com.badlogic.gdx.graphics.g2d.TextureRegion;
28 import com.badlogic.gdx.scenes.scene2d.Stage;
29 import com.badlogic.gdx.scenes.scene2d.ui.Image;
30 import com.badlogic.gdx.tests.utils.GdxTest;
31 
32 public class GroupFadeTest extends GdxTest {
33 
34 	Texture texture;
35 	Stage stage;
36 
37 	@Override
create()38 	public void create () {
39 		texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
40 		stage = new Stage();
41 
42 		for (int i = 0; i < 100; i++) {
43 			Image img = new Image(new TextureRegion(texture));
44 			img.setX((float)Math.random() * 480);
45 			img.setY((float)Math.random() * 320);
46 			img.getColor().a = (float)Math.random() * 0.5f + 0.5f;
47 			stage.addActor(img);
48 		}
49 
50 		stage.getRoot().addAction(forever(sequence(fadeOut(3), fadeIn(3))));
51 	}
52 
53 	@Override
render()54 	public void render () {
55 		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
56 		stage.act(Gdx.graphics.getDeltaTime());
57 		stage.draw();
58 	}
59 
60 	@Override
dispose()61 	public void dispose () {
62 		texture.dispose();
63 		stage.dispose();
64 	}
65 }
66