Collected stars are shown on Levelbuttons
This commit is contained in:
@ -4,7 +4,6 @@ import com.example.julian.endlessroll.data.Vector;
|
||||
import com.example.julian.endlessroll.levels.MoveComponent;
|
||||
import com.example.julian.endlessroll.levels.ObstacleData;
|
||||
import com.example.julian.endlessroll.levels.worlds.World;
|
||||
import com.example.julian.endlessroll.main.GameLog;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -30,7 +29,8 @@ public class Obstacle extends Entity {
|
||||
this.floating = data.isFloating();
|
||||
this.moving = data.isMoving();
|
||||
this.moveComponent = data.getMoveComponent();
|
||||
moveComponent.shrink(new Vector(super.getWidth(), super.getHeight()));
|
||||
if (moveComponent != null)
|
||||
moveComponent.shrink(new Vector(super.getWidth(), super.getHeight()));
|
||||
|
||||
if (!floating)
|
||||
super.setToTerrain(terrainEdge);
|
||||
@ -75,9 +75,9 @@ public class Obstacle extends Entity {
|
||||
private void setTextureAtlasIndex() {
|
||||
if (deadly && floating)
|
||||
super.getTexture().setAtlasIndex(1);
|
||||
else if(deadly)
|
||||
else if (deadly)
|
||||
super.getTexture().setAtlasIndex(2);
|
||||
else if(floating)
|
||||
else if (floating)
|
||||
super.getTexture().setAtlasIndex(0);
|
||||
else
|
||||
super.getTexture().setAtlasIndex(3);
|
||||
|
@ -54,8 +54,7 @@ public class LevelsScreen extends Screen<LinearLayout> implements View.OnClickLi
|
||||
private void createButton(Context context, Level level, int levelCount) {
|
||||
int levelNumber = level.getNumber();
|
||||
LevelButton button = new LevelButton(context, typeface, this, levelNumber, !level.isUnlocked());
|
||||
//TODO: light only collected star
|
||||
button.setStarCount(level.getCollectedStars().length());
|
||||
button.showCollectedStars(level.isFirstStarCollected(), level.isSecondStarCollected(), level.isThirdStarCollected());
|
||||
levelButtons.put(levelNumber, button);
|
||||
int halfLevelCount = levelCount / 2;
|
||||
if(levelCount % 2 == 1)
|
||||
|
@ -15,7 +15,9 @@ import com.example.julian.endlessroll.R;
|
||||
public class LevelButton extends RelativeLayout {
|
||||
|
||||
private TextView text;
|
||||
private ImageView starImage;
|
||||
private ImageView star1;
|
||||
private ImageView star2;
|
||||
private ImageView star3;
|
||||
private ImageView lockImage;
|
||||
|
||||
public LevelButton(Context context, Typeface typeface, OnClickListener clickListener, int level, boolean locked) {
|
||||
@ -26,7 +28,9 @@ public class LevelButton extends RelativeLayout {
|
||||
|
||||
text = (TextView) super.findViewById(R.id.levelbutton_textview);
|
||||
text.setTypeface(typeface);
|
||||
starImage = (ImageView) super.findViewById(R.id.levelbutton_starimage);
|
||||
star1 = (ImageView) super.findViewById(R.id.levelbutton_star1);
|
||||
star2 = (ImageView) super.findViewById(R.id.levelbutton_star2);
|
||||
star3 = (ImageView) super.findViewById(R.id.levelbutton_star3);
|
||||
lockImage = (ImageView) super.findViewById(R.id.levelbutton_lock);
|
||||
|
||||
setLockVisible(locked);
|
||||
@ -38,16 +42,13 @@ public class LevelButton extends RelativeLayout {
|
||||
lockImage.setVisibility(visibility);
|
||||
}
|
||||
|
||||
public void setStarCount(int count) {
|
||||
if (count == 0) {
|
||||
starImage.setImageResource(R.drawable.stars_0);
|
||||
} else if (count == 1) {
|
||||
starImage.setImageResource(R.drawable.stars_1);
|
||||
} else if (count == 2) {
|
||||
starImage.setImageResource(R.drawable.stars_2);
|
||||
} else {
|
||||
starImage.setImageResource(R.drawable.stars_3);
|
||||
}
|
||||
public void showCollectedStars(boolean star1, boolean star2, boolean star3) {
|
||||
if(star1)
|
||||
this.star1.setImageResource(R.drawable.star);
|
||||
if(star2)
|
||||
this.star2.setImageResource(R.drawable.star);
|
||||
if(star3)
|
||||
this.star3.setImageResource(R.drawable.star);
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
|
BIN
app/src/main/res/drawable/star_empty.png
Normal file
BIN
app/src/main/res/drawable/star_empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
Before Width: | Height: | Size: 4.2 KiB |
@ -14,13 +14,35 @@
|
||||
android:textSize="30sp"
|
||||
android:layout_centerHorizontal="true" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/levelbutton_starimage"
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="70dp"
|
||||
android:src="@drawable/stars_0"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="50dp"/>
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/star_empty"
|
||||
android:id="@+id/levelbutton_star1"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/star_empty"
|
||||
android:id="@+id/levelbutton_star2"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/star_empty"
|
||||
android:id="@+id/levelbutton_star3"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/levelbutton_lock"
|
||||
@ -28,6 +50,7 @@
|
||||
android:layout_height="100dp"
|
||||
android:src="@drawable/lock_locked"
|
||||
android:layout_centerInParent="true"
|
||||
android:visibility="invisible"/>
|
||||
android:visibility="invisible"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</RelativeLayout>
|
Reference in New Issue
Block a user