TEST SCREEN
Did I say fast before, but nothing like this. I will show you to meaning of fast. In 25 line of codes (without comments), you are going to implement these:
-
Not much to say run the code from project, read comments and documentations
Did I say fast before, but nothing like this. I will show you to meaning of fast. In 25 line of codes (without comments), you are going to implement these:
- Level button table
- Sliding animation action for the table
- Fully customizable ButtonLevels with %100 functionality
- Set button textures, star holders, stars or any other achievement objects you want (coins, bottles, points ...)
- Set the earned stars from database or text files
- Lock the the levels which you desire (from database or text file) with a texture you want
- MORE MORE MORE...
-
Not much to say run the code from project, read comments and documentations
private void setUpLevelsScreen() {
// Create levels table
// ######################################################################
levelsTable1 = MenuCreator.createTable(true, Assets.getSkin());
levelsTable1.setPosition(-999, 0);
levelsTable1.addAction(Actions.moveTo(0, 0, 0.7f));
levelsTable1.top().left().pad(30, 30, 30, 30);
// Add to stage
// ######################################################################
getStage().addActor(levelsTable1);
// Add levels buttons
// Normally get this number from textfiles or database
// ######################################################################
int numberOfLevels = 20;
// Create buttons with a loop
for (int i = 0; i < numberOfLevels; i++){
//1. Create level button
final ButtonLevel levelButton = MenuCreator.createCustomLevelButton(Assets.btnLevel,Assets.btnLevelPressed);
//2. Set level number
levelButton.setLevelNumber(i + 1, Assets.font2);
//3. Set lock condition (get from database if it is locked or not and lock it)
// use if/else here to lock or not
// levelButton.setTextureLocked(Assets.btnBatLocked, true);
//4. Set stars or any other achievements (get from database or text files here)
// I just made a random number of earned stars
Random rnd = new Random();
levelButton.setLevelStars(Assets.imgStarHolder, Assets.imgStar, 3, rnd.nextInt(3) + 1);
//5. Add listener
//Add button listener to go to a level (gamascreen)
levelButton.addListener(new ActorGestureListener() {
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
}
});
//6. Add row after each 5 level button to go down or how many do you need
if(i % 5 == 0){
levelsTable1.row();
}
// Add to table
levelsTable1.add(levelButton).size(100, 100).pad(5, 5, 5, 5).expand();
}
}
0 yorum:
Yorum Gönder