initial commit for archival.
|
|
@ -0,0 +1,39 @@
|
|||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Log/OS Files
|
||||
*.log
|
||||
|
||||
# Android Studio generated files and folders
|
||||
captures/
|
||||
.externalNativeBuild/
|
||||
.cxx/
|
||||
*.apk
|
||||
output.json
|
||||
|
||||
# IntelliJ
|
||||
*.iml
|
||||
.idea/
|
||||
misc.xml
|
||||
deploymentTargetDropDown.xml
|
||||
render.experimental.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# Google Services (e.g. APIs or Firebase)
|
||||
google-services.json
|
||||
|
||||
# Android Profiling
|
||||
*.hprof
|
||||
|
||||
# Output
|
||||
gen/
|
||||
libs/
|
||||
bin/
|
||||
out/
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.hkri.HoppyGirl"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="15"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
<activity android:name="Hoppy_Girl"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<meta-data android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version" />
|
||||
<activity android:name="com.google.android.gms.ads.AdActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
|
||||
android:theme="@android:style/Theme.Translucent" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
Copyright 2014 John Espiritu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Hoppy Girl
|
||||
|
||||
Hoppy Girl is a infinite running game for Android.
|
||||
|
||||
## Status
|
||||
|
||||
The project was developed for the old platforms. For this reason, it is archived for historical purposes and is no longer being maintained or updated.
|
||||
|
||||
## Author
|
||||
|
||||
* John Espiritu
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# This file is used to override default values used by the Ant build system.
|
||||
#
|
||||
# This file must be checked into Version Control Systems, as it is
|
||||
# integral to the build system of your project.
|
||||
|
||||
# This file is only used by the Ant script.
|
||||
|
||||
# You can use this to override default values such as
|
||||
# 'source.dir' for the location of your java source folder and
|
||||
# 'out.dir' for the location of your output folder.
|
||||
|
||||
# You can also use it define how the release builds are signed by declaring
|
||||
# the following properties:
|
||||
# 'key.store' for the location of your keystore and
|
||||
# 'key.alias' for the name of the key to use.
|
||||
# The password will be asked during the build when you use the 'release' target.
|
||||
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.7 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="Hoppy_Girl" default="help">
|
||||
|
||||
<!-- The local.properties file is created and updated by the 'android' tool.
|
||||
It contains the path to the SDK. It should *NOT* be checked into
|
||||
Version Control Systems. -->
|
||||
<property file="local.properties"/>
|
||||
|
||||
<!-- The ant.properties file can be created by you. It is only edited by the
|
||||
'android' tool to add properties to it.
|
||||
This is the place to change some Ant specific build properties.
|
||||
Here are some properties you may want to change/update:
|
||||
|
||||
source.dir
|
||||
The name of the source directory. Default is 'src'.
|
||||
out.dir
|
||||
The name of the output directory. Default is 'bin'.
|
||||
|
||||
For other overridable properties, look at the beginning of the rules
|
||||
files in the SDK, at tools/ant/build.xml
|
||||
|
||||
Properties related to the SDK location or the project target should
|
||||
be updated using the 'android' tool with the 'update' action.
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems.
|
||||
|
||||
-->
|
||||
<property file="ant.properties"/>
|
||||
|
||||
<!-- if sdk.dir was not set from one of the property file, then
|
||||
get it from the ANDROID_HOME env var.
|
||||
This must be done before we load project.properties since
|
||||
the proguard config can use sdk.dir -->
|
||||
<property environment="env"/>
|
||||
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
|
||||
<isset property="env.ANDROID_HOME"/>
|
||||
</condition>
|
||||
|
||||
<!-- The project.properties file is created and updated by the 'android'
|
||||
tool, as well as ADT.
|
||||
|
||||
This contains project specific properties such as project target, and library
|
||||
dependencies. Lower level build properties are stored in ant.properties
|
||||
(or in .classpath for Eclipse projects).
|
||||
|
||||
This file is an integral part of the build system for your
|
||||
application and should be checked into Version Control Systems. -->
|
||||
<loadproperties srcFile="project.properties"/>
|
||||
|
||||
<!-- quick check on sdk.dir -->
|
||||
<fail
|
||||
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
|
||||
unless="sdk.dir"
|
||||
/>
|
||||
|
||||
<!--
|
||||
Import per project custom build rules if present at the root of the project.
|
||||
This is the place to put custom intermediary targets such as:
|
||||
-pre-build
|
||||
-pre-compile
|
||||
-post-compile (This is typically used for code obfuscation.
|
||||
Compiled code location: ${out.classes.absolute.dir}
|
||||
If this is not done in place, override ${out.dex.input.absolute.dir})
|
||||
-post-package
|
||||
-post-build
|
||||
-pre-clean
|
||||
-->
|
||||
<import file="custom_rules.xml" optional="true"/>
|
||||
|
||||
<!-- Import the actual build file.
|
||||
|
||||
To customize existing targets, there are two options:
|
||||
- Customize only one target:
|
||||
- copy/paste the target into this file, *before* the
|
||||
<import> task.
|
||||
- customize it to your needs.
|
||||
- Customize the whole content of build.xml
|
||||
- copy/paste the content of the rules files (minus the top node)
|
||||
into this file, replacing the <import> task.
|
||||
- customize to your needs.
|
||||
|
||||
***********************
|
||||
****** IMPORTANT ******
|
||||
***********************
|
||||
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
|
||||
in order to avoid having your file be overridden by tools such as "android update project"
|
||||
-->
|
||||
<!-- version-tag: 1 -->
|
||||
<import file="${sdk.dir}/tools/ant/build.xml"/>
|
||||
|
||||
</project>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# To enable ProGuard in your project, edit project.properties
|
||||
# to define the proguard.config property as described in that file.
|
||||
#
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in ${sdk.dir}/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the ProGuard
|
||||
# include property in project.properties.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-15
|
||||
android.library=false
|
||||
android.library.reference.1=../../Documents/Programming/~Libraries/AndEngine-GLES2
|
||||
android.library.reference.2=../../../../adt-bundle-windows-x86_64-20131030/sdk/extras/google/google_play_services/libproject/google-play-services_lib
|
||||
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World, Hoppy_Girl"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Hoppy Girl</string>
|
||||
<string name = "ad_unit_id">ca-app-pub-4163275117282430/4666967907</string>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 27, 2014
|
||||
*
|
||||
*/
|
||||
|
||||
public class CloudsBG {
|
||||
|
||||
ITextureRegion mRegion;
|
||||
Engine mEngine;
|
||||
|
||||
Sprite mCloudSprite;
|
||||
|
||||
public CloudsBG(ITextureRegion rgn, Engine ngn) {
|
||||
mRegion = rgn;
|
||||
mEngine = ngn;
|
||||
}
|
||||
|
||||
public void attachSprite(Scene scn, float pX, float pY){
|
||||
mCloudSprite = new Sprite(pX, pY, mRegion, mEngine.getVertexBufferObjectManager());
|
||||
scn.attachChild(mCloudSprite);
|
||||
}
|
||||
|
||||
public Sprite getSprite(){ return mCloudSprite; }
|
||||
|
||||
public float getW(){ return mCloudSprite.getWidth(); }
|
||||
|
||||
public float getH(){ return mCloudSprite.getHeight(); }
|
||||
|
||||
public float getX(){ return mCloudSprite.getX(); }
|
||||
|
||||
public float getY(){ return mCloudSprite.getY(); }
|
||||
|
||||
public void setX(float pX) { mCloudSprite.setX(pX); }
|
||||
|
||||
public void setY(float pY) { mCloudSprite.setX(pY); }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.entity.primitive.Rectangle;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 30, 2014
|
||||
*
|
||||
*/
|
||||
|
||||
public class CrystalObstacles {
|
||||
|
||||
//Crystal Regions
|
||||
ITextureRegion crystalRegion1, crystalRegion2, crystalRegion3;
|
||||
Sprite crystalSprite;
|
||||
int currentCrystalType = -1;
|
||||
|
||||
//Passed flag
|
||||
public boolean obstacleChecked = false;
|
||||
|
||||
//Game settings
|
||||
Engine mEngine;
|
||||
|
||||
//Hit area
|
||||
Rectangle[] hitArea = new Rectangle[4];
|
||||
|
||||
public CrystalObstacles(ITextureRegion c1, ITextureRegion c2, ITextureRegion c3, Engine ngn){
|
||||
crystalRegion1 = c1; crystalRegion2 = c2; crystalRegion3 = c3;
|
||||
mEngine = ngn;
|
||||
}
|
||||
|
||||
public void disposeObject(Scene scn){
|
||||
scn.detachChild(crystalSprite);
|
||||
for(Rectangle rt : hitArea)
|
||||
if(rt.isDisposed() == false )rt.dispose();
|
||||
if(crystalSprite.isDisposed() == false )crystalSprite.dispose();
|
||||
}
|
||||
|
||||
public void attachCrystal(Scene scn, float pX, float pYBottom, int crystalType){
|
||||
hitArea = new Rectangle[4];
|
||||
currentCrystalType = crystalType;
|
||||
if(crystalType == 0) {
|
||||
crystalSprite = new Sprite(pX, pYBottom, crystalRegion1, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[0] = new Rectangle(getX(), getY() + 19, 22, 64, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[1] = new Rectangle(getX() + 9, getY(), 6, 18, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[2] = new Rectangle(getX() + 5, getY() + 10, 14, 9, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[3] = new Rectangle(getX() + 2, getY() + 14, 18, 4, mEngine.getVertexBufferObjectManager());
|
||||
}
|
||||
else if(crystalType == 1) {
|
||||
crystalSprite = new Sprite(pX, pYBottom, crystalRegion2, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[0] = new Rectangle(getX(), getY() + 18, 22, 34, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[1] = new Rectangle(getX() + 9, getY() + 1, 6, 18, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[2] = new Rectangle(getX() + 4, getY() + 10, 14, 8, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[3] = new Rectangle(getX() + 2, getY() + 14, 18, 4, mEngine.getVertexBufferObjectManager());
|
||||
}
|
||||
else if(crystalType == 2) {
|
||||
crystalSprite = new Sprite(pX, pYBottom, crystalRegion3, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[0] = new Rectangle(getX() + 10, getY() + 30, 34, 46, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[1] = new Rectangle(getX() + 1, getY() + 44, 10, 32, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[2] = new Rectangle(getX() + 30, getY() + 0, 6, 35, mEngine.getVertexBufferObjectManager());
|
||||
hitArea[3] = new Rectangle(getX() + 22, getY() + 14, 22, 20, mEngine.getVertexBufferObjectManager());
|
||||
}
|
||||
crystalSprite.setY(crystalSprite.getY() - crystalSprite.getHeight());
|
||||
scn.attachChild(crystalSprite);
|
||||
}
|
||||
|
||||
public Rectangle[] getCollidingRectangles(){
|
||||
return hitArea;
|
||||
}
|
||||
|
||||
private void updateColliderPosition(){
|
||||
if(currentCrystalType == 0) {
|
||||
hitArea[0].setPosition(getX(), getY() + 19);
|
||||
hitArea[1].setPosition(getX() + 9, getY());
|
||||
hitArea[2].setPosition(getX() + 5, getY() + 10);
|
||||
hitArea[3].setPosition(getX() + 2, getY() + 14);
|
||||
}
|
||||
else if(currentCrystalType == 1) {
|
||||
hitArea[0].setPosition(getX(), getY() + 18);
|
||||
hitArea[1].setPosition(getX() + 9, getY() + 1);
|
||||
hitArea[2].setPosition(getX() + 4, getY() + 10);
|
||||
hitArea[3].setPosition(getX() + 2, getY() + 14);
|
||||
}
|
||||
else if(currentCrystalType == 2) {
|
||||
hitArea[0].setPosition(getX() + 10, getY() + 30);
|
||||
hitArea[1].setPosition(getX() + 1, getY() + 44);
|
||||
hitArea[2].setPosition(getX() + 30, getY() + 0);
|
||||
hitArea[3].setPosition(getX() + 22, getY() + 14);
|
||||
}
|
||||
}
|
||||
|
||||
public Sprite getSprite(){
|
||||
return crystalSprite;
|
||||
}
|
||||
|
||||
public void setX(float nval) { crystalSprite.setX(nval); updateColliderPosition(); }
|
||||
public void setY(float nval) { crystalSprite.setY(nval); updateColliderPosition(); }
|
||||
public float getX() { return crystalSprite.getX();}
|
||||
public float getY() { return crystalSprite.getY();}
|
||||
public float getW() { return crystalSprite.getWidth();}
|
||||
public float getH() { return crystalSprite.getHeight();}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 29, 2014
|
||||
*
|
||||
*/
|
||||
|
||||
public class Floor {
|
||||
|
||||
Sprite floorSprite;
|
||||
ITextureRegion floorRegion;
|
||||
Engine mEngine;
|
||||
|
||||
public Floor(ITextureRegion rgn, Engine ngn){
|
||||
floorRegion = rgn;
|
||||
mEngine = ngn;
|
||||
}
|
||||
|
||||
public void attachSprite(Scene pScene, float pX, float pY){
|
||||
floorSprite = new Sprite(pX, pY, floorRegion, mEngine.getVertexBufferObjectManager());
|
||||
pScene.attachChild(floorSprite);
|
||||
}
|
||||
|
||||
public Sprite getFloorSprite(){
|
||||
return floorSprite;
|
||||
}
|
||||
|
||||
public float getSpriteW(){
|
||||
return floorSprite.getWidth();
|
||||
}
|
||||
|
||||
public float getSpriteH() {
|
||||
return floorSprite.getHeight();
|
||||
}
|
||||
|
||||
public void setSpriteX(float nVal){
|
||||
floorSprite.setX(nVal);
|
||||
}
|
||||
|
||||
public void setSpriteY(float nVal){
|
||||
floorSprite.setY(nVal);
|
||||
}
|
||||
|
||||
public float getSpriteX(){
|
||||
return floorSprite.getX();
|
||||
}
|
||||
|
||||
public float getSpriteY(){
|
||||
return floorSprite.getY();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,733 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.audio.sound.Sound;
|
||||
import org.andengine.audio.sound.SoundFactory;
|
||||
import org.andengine.engine.camera.Camera;
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.engine.handler.timer.ITimerCallback;
|
||||
import org.andengine.engine.handler.timer.TimerHandler;
|
||||
import org.andengine.entity.IEntity;
|
||||
import org.andengine.entity.modifier.AlphaModifier;
|
||||
import org.andengine.entity.modifier.DelayModifier;
|
||||
import org.andengine.entity.modifier.SequenceEntityModifier;
|
||||
import org.andengine.entity.primitive.Rectangle;
|
||||
import org.andengine.entity.scene.IOnSceneTouchListener;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.scene.background.Background;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.entity.sprite.TiledSprite;
|
||||
import org.andengine.input.touch.TouchEvent;
|
||||
import org.andengine.opengl.texture.TextureManager;
|
||||
import org.andengine.opengl.texture.TextureOptions;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BuildableBitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource;
|
||||
import org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder;
|
||||
import org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
import org.andengine.opengl.texture.region.ITiledTextureRegion;
|
||||
import org.andengine.ui.activity.SimpleBaseGameActivity;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
|
||||
import org.andengine.util.debug.Debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 26, 2014
|
||||
*
|
||||
*/
|
||||
|
||||
public class GameScreen extends Scene implements IOnSceneTouchListener {
|
||||
|
||||
//Sounds!
|
||||
Sound selectSound;
|
||||
Sound dieSound;
|
||||
|
||||
//Scoring sprites
|
||||
BitmapTextureAtlas scoreDigitAtlas;
|
||||
ITextureRegion mScoreLabelMain;
|
||||
BuildableBitmapTextureAtlas scoreDigitsAtlas;
|
||||
ITiledTextureRegion mNumbersRegion;
|
||||
Sprite mScoreLabelMainSprite;
|
||||
ArrayList<TiledSprite> scoreDigitsMain = new ArrayList<TiledSprite>();
|
||||
ArrayList<TiledSprite> scoreDigitsScoreboard = new ArrayList<TiledSprite>();
|
||||
ArrayList<TiledSprite> scoreDigitsScoreboardBest = new ArrayList<TiledSprite>();
|
||||
|
||||
//Button elements
|
||||
ITextureRegion mReplayButtonRegion;
|
||||
ITextureRegion mLeaderboardButtonRegion;
|
||||
|
||||
//Scoreboard elements
|
||||
ITextureRegion mGameoverRegion;
|
||||
Sprite mGameoverSprite;
|
||||
Sprite mLeaderboardButtonSprite;
|
||||
Sprite mReplayButtonSprite;
|
||||
ITextureRegion mCrownRegion;
|
||||
Sprite mCrownSprite;
|
||||
|
||||
//Crash cover
|
||||
Rectangle crashCover;
|
||||
|
||||
//Game atlas.
|
||||
BitmapTextureAtlas bmpAtlas;
|
||||
BitmapTextureAtlas crystalAtlas;
|
||||
|
||||
//Crystal regions
|
||||
ITextureRegion mCrystal1Region, mCrystal2Region, mCrystal3Region;
|
||||
|
||||
//Cover sprite
|
||||
ITextureRegion mCoverRegion;
|
||||
Sprite mCoverSprite;
|
||||
|
||||
//Guide variable
|
||||
ITextureRegion mGetReadyRegion;
|
||||
Sprite mGetReadySprite;
|
||||
|
||||
//Floor variables
|
||||
ITextureRegion mFloorRegion;
|
||||
float FLOOR_Y = 0.0f;
|
||||
float FLOOR_VELOCITY = 5f;
|
||||
|
||||
//Cloud variables
|
||||
ITextureRegion mCloudRegion;
|
||||
float CLOUD_VELOCITY = 1f;
|
||||
float CLOUD_Y = 40f;
|
||||
|
||||
//Collections
|
||||
ArrayList<Floor> lstFloors = new ArrayList<Floor>();
|
||||
ArrayList<CloudsBG> lstClouds = new ArrayList<CloudsBG>();
|
||||
|
||||
//Obstacle collections
|
||||
ArrayList<CrystalObstacles> lstCrystalO = new ArrayList<CrystalObstacles>();
|
||||
|
||||
//Activity properties
|
||||
TextureManager mTManager;
|
||||
SimpleBaseGameActivity mActivity;
|
||||
Engine mEngine;
|
||||
Camera mCamera;
|
||||
boolean gameoverShown = false;
|
||||
|
||||
//Player variable
|
||||
Player mPlayer;
|
||||
int gameScore = 0;
|
||||
boolean scoreMainVisible = false;
|
||||
float mTime = 0;
|
||||
|
||||
//Obstacle variable
|
||||
float[] crystalObstacleIntervals = { 36f, 45f, 75f, 10f, 55f, 50f, 25f};
|
||||
float crystalObstacleCurrentInterval = 50f;
|
||||
float crystalObstacleCtr = 0;
|
||||
int consecutiveClose = 0;
|
||||
|
||||
//Scorer obstacle jumped
|
||||
Rectangle scoreChecker;
|
||||
|
||||
public GameScreen(final SimpleBaseGameActivity actvt, TextureManager tmgr, Engine engn, Camera cm){
|
||||
//Setup activity properties
|
||||
mTManager = tmgr;
|
||||
mActivity = actvt;
|
||||
mEngine = engn;
|
||||
mCamera = cm;
|
||||
|
||||
loadResources(); //Load resources to memory.
|
||||
|
||||
setOnSceneTouchListener(this); //Set screen touch listener
|
||||
setTouchAreaBindingOnActionDownEnabled(true);
|
||||
|
||||
//Setup score text main
|
||||
mScoreLabelMainSprite = new Sprite(mCamera.getWidth() - mScoreLabelMain.getWidth() - 15f, 15f, mScoreLabelMain, mEngine.getVertexBufferObjectManager());
|
||||
mScoreLabelMainSprite.setZIndex(5);
|
||||
mScoreLabelMainSprite.setAlpha(0f);
|
||||
attachChild(mScoreLabelMainSprite);
|
||||
|
||||
//FLOOR_Y = (mPlayer.getPlayerSprite().getY() + mPlayer.getPlayerSprite().getHeight());
|
||||
FLOOR_Y = (mCamera.getHeight() - 60f);
|
||||
|
||||
//Setup scene background
|
||||
setBackground(new Background(Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237)));
|
||||
|
||||
//Add fader (fade in)
|
||||
mCoverSprite = new Sprite(0, 0, mCoverRegion, mEngine.getVertexBufferObjectManager());
|
||||
mCoverSprite.registerEntityModifier(new AlphaModifier(0.3f, 1.0f, 0.0f));
|
||||
mCoverSprite.setSize(cm.getWidth(), cm.getHeight());
|
||||
mCoverSprite.setZIndex(100);
|
||||
attachChild(mCoverSprite);
|
||||
|
||||
//scoreboard labels setup
|
||||
mGameoverSprite = new Sprite((mCamera.getWidth() - mGameoverRegion.getWidth()) * 0.5f - 30f, 105f, mGameoverRegion, mEngine.getVertexBufferObjectManager());
|
||||
mGameoverSprite.setZIndex(110);
|
||||
mGameoverSprite.setAlpha(0.0f);
|
||||
attachChild(mGameoverSprite);
|
||||
|
||||
//Crash white cover
|
||||
crashCover = new Rectangle(0, 0, mCamera.getWidth(), mCamera.getHeight(), mEngine.getVertexBufferObjectManager());
|
||||
crashCover.setColor(Hoppy_Girl.getClr(237),Hoppy_Girl.getClr(237),Hoppy_Girl.getClr(237));
|
||||
crashCover.setAlpha(0f);
|
||||
crashCover.setZIndex(99);
|
||||
attachChild(crashCover);
|
||||
|
||||
while(getLastCloudRight() < mCamera.getWidth() + 50f) addCloud();
|
||||
|
||||
while(getLastFloorRight() < mCamera.getWidth() + 50f) addFloor();
|
||||
|
||||
//Add player
|
||||
mPlayer = new Player(mActivity, mTManager, mEngine);
|
||||
mPlayer.getPlayerSprite().setPosition(50f, FLOOR_Y - mPlayer.getPlayerSprite().getHeight());
|
||||
mPlayer.setFloorLimit(FLOOR_Y - mPlayer.getPlayerSprite().getHeight());
|
||||
mPlayer.attachPlayerSprite(this);
|
||||
|
||||
//SCORE CHECKER SETUP
|
||||
scoreChecker = new Rectangle(mPlayer.getPlayerSprite().getX(), FLOOR_Y - 30f, 10f, 30f, mEngine.getVertexBufferObjectManager());
|
||||
scoreChecker.setColor(org.andengine.util.color.Color.TRANSPARENT);
|
||||
attachChild(scoreChecker);
|
||||
|
||||
//Add scoreboard buttons
|
||||
mReplayButtonSprite = new Sprite((mCamera.getWidth() - mReplayButtonRegion.getWidth()) * 0.5f - (mReplayButtonRegion.getWidth() * 0.5f + 15f), 265f, mReplayButtonRegion, mEngine.getVertexBufferObjectManager()) {
|
||||
boolean isPressed = false;
|
||||
@Override
|
||||
public boolean onAreaTouched(TouchEvent e, float pX, float pY){
|
||||
if(e.getAction() == TouchEvent.ACTION_UP) {
|
||||
isPressed = false;
|
||||
mReplayButtonSprite.setY(mReplayButtonSprite.getY() - 3f);
|
||||
if (Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.GAMEOVER) {
|
||||
if (gameoverShown) {
|
||||
resetGame();
|
||||
selectSound.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(e.getAction() == TouchEvent.ACTION_DOWN){
|
||||
isPressed = true;
|
||||
mReplayButtonSprite.setY(mReplayButtonSprite.getY() + 3f);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
mReplayButtonSprite.setZIndex(110);
|
||||
mReplayButtonSprite.setAlpha(0f);
|
||||
attachChild(mReplayButtonSprite);
|
||||
|
||||
mLeaderboardButtonSprite = new Sprite((mCamera.getWidth() - mLeaderboardButtonRegion.getWidth()) * 0.5f + (mLeaderboardButtonRegion.getWidth() * 0.5f + 15f), 265f, mLeaderboardButtonRegion, mEngine.getVertexBufferObjectManager());
|
||||
mLeaderboardButtonSprite.setZIndex(110);
|
||||
mLeaderboardButtonSprite.setAlpha(0f);
|
||||
attachChild(mLeaderboardButtonSprite);
|
||||
|
||||
//Add get ready
|
||||
float grW = mGetReadyRegion.getWidth() * 1.50f, grH = mGetReadyRegion.getHeight() * 1.50f;
|
||||
mGetReadySprite = new Sprite((mCamera.getWidth() - grW) * 0.5f, 90f, mGetReadyRegion, mEngine.getVertexBufferObjectManager());
|
||||
mGetReadySprite.setSize(grW, grH);
|
||||
attachChild(mGetReadySprite);
|
||||
|
||||
//Add crown icon
|
||||
mCrownSprite = new Sprite(mGameoverSprite.getWidth() * 0.5f + mGameoverSprite.getX() + 140f, mGameoverSprite.getY() + 4f, mCrownRegion, mEngine.getVertexBufferObjectManager());
|
||||
mCrownSprite.setAlpha(0f);
|
||||
mCrownSprite.setZIndex(103);
|
||||
attachChild(mCrownSprite);
|
||||
|
||||
setScoresDigits(mCamera.getWidth() - 15f, 42f, 7); //setup score digits on game screen
|
||||
|
||||
sortChildren();
|
||||
hideScoreMain();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onManagedUpdate(final float mSecondsElapsed){
|
||||
|
||||
if(Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.READY || Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.RUNNING || Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.GAMEOVER) {
|
||||
|
||||
//------------ basic elements ------------------------
|
||||
//Infinite floors and clouds
|
||||
if(Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.READY || Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.RUNNING) {
|
||||
moveFloors();
|
||||
moveClouds();
|
||||
removeOffscreenCloud();
|
||||
removeOffscreenFloor();
|
||||
if (getLastCloudRight() < mCamera.getWidth() + 50f) addCloud();
|
||||
if (getLastFloorRight() < mCamera.getWidth() + 50f) addFloor();
|
||||
}
|
||||
|
||||
//---------- obstacles ------------------
|
||||
if(Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.RUNNING) {
|
||||
|
||||
//----------------------- INCREMENT SCORE --------------------------
|
||||
// mTime += mSecondsElapsed;
|
||||
// if(mTime >= 0.005f){
|
||||
// gameScore++;
|
||||
// mTime = 0;
|
||||
// }
|
||||
// setScoreMain(gameScore);
|
||||
checkPassedCrystalObstacles();
|
||||
if(gameScore == 200){
|
||||
FLOOR_VELOCITY = 6f;
|
||||
}
|
||||
|
||||
//---------------------- CRYSTALS -----------------------------------
|
||||
//Move crystals
|
||||
moveCrystalObstacles();
|
||||
removeOffscreenCrystalObstacles();
|
||||
|
||||
//Create crystal obstacle
|
||||
float speedIndependentCrystalCurrentInterval = (5f / FLOOR_VELOCITY) * crystalObstacleCurrentInterval;
|
||||
if (crystalObstacleCtr >= speedIndependentCrystalCurrentInterval) {
|
||||
spawnCrystalObstacle();
|
||||
setNextCrystalObstacleInterval();
|
||||
if(crystalObstacleCurrentInterval < 30f)
|
||||
consecutiveClose++;
|
||||
else
|
||||
consecutiveClose = 0;
|
||||
if(consecutiveClose == 3) {
|
||||
crystalObstacleCurrentInterval = 55f;
|
||||
consecutiveClose = 0;
|
||||
}
|
||||
crystalObstacleCtr = 0;
|
||||
}
|
||||
|
||||
//update obstacle counter.
|
||||
crystalObstacleCtr++;
|
||||
|
||||
//check collisions with crystal
|
||||
for(CrystalObstacles crys : lstCrystalO){
|
||||
if(mPlayer.playerCollidesWith(crys.getCollidingRectangles())){
|
||||
flashWhite();
|
||||
mPlayer.die();
|
||||
Hoppy_Girl.currentState = Hoppy_Girl.GAMESTATE.GAMEOVER;
|
||||
registerUpdateHandler(new TimerHandler(1f, new ITimerCallback() {
|
||||
@Override
|
||||
public void onTimePassed(TimerHandler pTimerHandler) {
|
||||
setGameOver();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
}
|
||||
//----------------------------------------
|
||||
|
||||
//------------- player -------------------------------
|
||||
|
||||
//Update player position
|
||||
mPlayer.update(mSecondsElapsed);
|
||||
|
||||
//---------------------------------------------------
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
super.onManagedUpdate(mSecondsElapsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSceneTouchEvent(Scene scn, TouchEvent e){
|
||||
if(e.isActionDown()){
|
||||
if(Hoppy_Girl.currentState != Hoppy_Girl.GAMESTATE.GAMEOVER) {
|
||||
if (Hoppy_Girl.currentState == Hoppy_Girl.GAMESTATE.READY) {
|
||||
Hoppy_Girl.currentState = Hoppy_Girl.GAMESTATE.RUNNING;
|
||||
mGetReadySprite.registerEntityModifier(new AlphaModifier(0.5f, 1.0f, 0.0f));
|
||||
mScoreLabelMainSprite.registerEntityModifier(new AlphaModifier(1f, 0f, 1f));
|
||||
showScoreMain(0);
|
||||
}
|
||||
if (Hoppy_Girl.currentState != Hoppy_Girl.GAMESTATE.GAMEOVER)
|
||||
mPlayer.jump();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void loadResources(){
|
||||
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
|
||||
|
||||
//--------------- SCORE DIGIT ASSETS -------------------------------
|
||||
scoreDigitAtlas = new BitmapTextureAtlas(mTManager, 85, 25, TextureOptions.NEAREST);
|
||||
mScoreLabelMain = BitmapTextureAtlasTextureRegionFactory.createFromAsset(scoreDigitAtlas, mActivity, "score_label_game.png", 0, 0);
|
||||
scoreDigitAtlas.load();
|
||||
|
||||
//-------------- SOUND ASSETS-------------------------
|
||||
SoundFactory.setAssetBasePath("sfx/");
|
||||
try {
|
||||
selectSound = SoundFactory.createSoundFromAsset(mActivity.getSoundManager(), mActivity, "selectsound.wav");
|
||||
selectSound.setVolume(0.3f);
|
||||
} catch (Exception ex){
|
||||
Debug.e(ex);
|
||||
}
|
||||
|
||||
|
||||
// ------------- MAIN ASSETS ----------------------------------------
|
||||
bmpAtlas = new BitmapTextureAtlas(mTManager, 480, 670, TextureOptions.NEAREST);
|
||||
|
||||
//Load cover resources.
|
||||
mCoverRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "black_bg.png", 0, 0);
|
||||
|
||||
//Load floor resources.
|
||||
mFloorRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "floor_tile.png", 0, 3);
|
||||
|
||||
//Load cloud resources
|
||||
mCloudRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "clouds_bg.png", 0, 92);
|
||||
|
||||
//Load region resources
|
||||
mGetReadyRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "get_ready.png", 0, 264);
|
||||
|
||||
//Score label region
|
||||
mGameoverRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "score_labels.png", 0, 381);
|
||||
|
||||
//Replay button
|
||||
mReplayButtonRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "replay_button.png", 0, 508);
|
||||
|
||||
//Leaderboard button
|
||||
mLeaderboardButtonRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "leaderboard_button.png", 0, 578);
|
||||
|
||||
//Crown icon
|
||||
mCrownRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "crown_highscore.png", 83, 4);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
//--------------- CRYSTAL OBSTACLE ASSET ------------------------------
|
||||
//Load crystal obstacles
|
||||
crystalAtlas = new BitmapTextureAtlas(mTManager, 50, 220, TextureOptions.NEAREST);
|
||||
|
||||
//Crystals
|
||||
mCrystal1Region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(crystalAtlas, mActivity, "crystal_1.png", 0, 0);
|
||||
mCrystal2Region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(crystalAtlas, mActivity, "crystal_2.png", 0, 84);
|
||||
mCrystal3Region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(crystalAtlas, mActivity, "crystal_3.png", 0, 137);
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
|
||||
//Load atlas
|
||||
crystalAtlas.load();
|
||||
bmpAtlas.load();
|
||||
}
|
||||
|
||||
public void hideScoreMain(){
|
||||
for(TiledSprite dig : scoreDigitsMain){
|
||||
dig.setAlpha(0f);
|
||||
}
|
||||
scoreMainVisible = false;
|
||||
}
|
||||
|
||||
public void showScoreMain(int score){
|
||||
scoreMainVisible = true;
|
||||
String str = score + "";
|
||||
setScoreMain(score);
|
||||
int spriteLast = scoreDigitsMain.size() - 1;
|
||||
for(int i = str.length() - 1; i >= 0; i--) {
|
||||
scoreDigitsMain.get(spriteLast).registerEntityModifier(new AlphaModifier(1f, 0f, 1f));
|
||||
spriteLast--;
|
||||
}
|
||||
while(spriteLast >= 0) {
|
||||
scoreDigitsMain.get(spriteLast).setAlpha(0f);
|
||||
spriteLast--;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPassedCrystalObstacles(){
|
||||
for(int i = 0; i < lstCrystalO.size(); i++){
|
||||
CrystalObstacles obs = lstCrystalO.get(i);
|
||||
if(scoreChecker.collidesWith(obs.getSprite())){
|
||||
if(obs.obstacleChecked == false) {
|
||||
obs.obstacleChecked = true;
|
||||
gameScore++;
|
||||
setScoreMain(gameScore);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScoresDigits(float pXRight, float pY, int digits){
|
||||
//------- SETUP DIGIT TEXTURE-------------
|
||||
scoreDigitsAtlas = new BuildableBitmapTextureAtlas(mTManager, 220, 40, TextureOptions.NEAREST);
|
||||
mNumbersRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(scoreDigitsAtlas, mActivity, "numbers_tiled.png", 10, 1);
|
||||
//Build Atlas.
|
||||
try {
|
||||
scoreDigitsAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1, 1, 4));
|
||||
scoreDigitsAtlas.load();
|
||||
} catch(ITextureAtlasBuilder.TextureAtlasBuilderException e){
|
||||
Debug.e(e);
|
||||
}
|
||||
|
||||
//-------- SETUP INGAME SCORE DIGITS ---------
|
||||
float digitsW = (21 * digits);
|
||||
float digitsX = pXRight - digitsW;
|
||||
for(int i = 0; i < digits; i++){
|
||||
TiledSprite sprt = new TiledSprite(digitsX + (21f * i), pY, mNumbersRegion, mEngine.getVertexBufferObjectManager());
|
||||
sprt.setCurrentTileIndex(0);
|
||||
scoreDigitsMain.add(sprt);
|
||||
attachChild(sprt);
|
||||
}
|
||||
|
||||
//---------- SETUP SCOREBOARD DIGITS ---------
|
||||
digitsX = mGameoverSprite.getWidth() * 0.5f + mGameoverSprite.getX() + 53f;
|
||||
float digitsSCScoreY = mGameoverSprite.getY() + 30f;
|
||||
float digitsSCBestY = mGameoverSprite.getY() + 97f;
|
||||
//Score digits
|
||||
for(int i = 0; i < digits; i++){
|
||||
TiledSprite sprt = new TiledSprite(digitsX + (21f * i), digitsSCScoreY, mNumbersRegion, mEngine.getVertexBufferObjectManager());
|
||||
sprt.setCurrentTileIndex(0);
|
||||
sprt.setZIndex(103);
|
||||
sprt.setAlpha(0f);
|
||||
scoreDigitsScoreboard.add(sprt);
|
||||
attachChild(sprt);
|
||||
//Best score digits.
|
||||
}for(int i = 0; i < digits; i++){
|
||||
TiledSprite sprt = new TiledSprite(digitsX + (21f * i), digitsSCBestY, mNumbersRegion, mEngine.getVertexBufferObjectManager());
|
||||
sprt.setCurrentTileIndex(0);
|
||||
sprt.setZIndex(103);
|
||||
sprt.setAlpha(0f);
|
||||
scoreDigitsScoreboardBest.add(sprt);
|
||||
attachChild(sprt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void hideScoreboardScores(){
|
||||
for(TiledSprite dig : scoreDigitsScoreboard){
|
||||
if(dig.getAlpha() > 0f) dig.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f));
|
||||
}
|
||||
for(TiledSprite dig : scoreDigitsScoreboardBest){
|
||||
if(dig.getAlpha() > 0f) dig.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f));
|
||||
}
|
||||
}
|
||||
|
||||
private void showScoreboardScores(){
|
||||
for(TiledSprite dig : scoreDigitsScoreboard){
|
||||
if(dig.getAlpha() > 0f) dig.registerEntityModifier(new AlphaModifier(0.4f, 0f, 1f));
|
||||
}
|
||||
for(TiledSprite dig : scoreDigitsScoreboardBest){
|
||||
if(dig.getAlpha() > 0f) dig.registerEntityModifier(new AlphaModifier(0.4f, 0f, 1f));
|
||||
}
|
||||
}
|
||||
|
||||
private void setScoreboardScore(int score, boolean showDigits){
|
||||
String str = score + "";
|
||||
int spriteLast = 0;
|
||||
for(int i = 0; i < str.length(); i++){
|
||||
int ndig = Integer.parseInt(str.charAt(i) + "");
|
||||
if(showDigits) scoreDigitsScoreboard.get(spriteLast).setAlpha(1f);
|
||||
else scoreDigitsScoreboard.get(spriteLast).setAlpha(0.01f);
|
||||
scoreDigitsScoreboard.get(spriteLast).setCurrentTileIndex(ndig);
|
||||
spriteLast++;
|
||||
}
|
||||
while(spriteLast < scoreDigitsScoreboard.size()) {
|
||||
if(showDigits) scoreDigitsScoreboard.get(spriteLast).setAlpha(0f);
|
||||
spriteLast++;
|
||||
}
|
||||
}
|
||||
|
||||
private void setScoreboardBestScore(int score, boolean showDigits){
|
||||
String str = score + "";
|
||||
int spriteLast = 0;
|
||||
for(int i = 0; i < str.length(); i++){
|
||||
int ndig = Integer.parseInt(str.charAt(i) + "");
|
||||
if(showDigits) scoreDigitsScoreboardBest.get(spriteLast).setAlpha(1f);
|
||||
else scoreDigitsScoreboardBest.get(spriteLast).setAlpha(0.01f);
|
||||
scoreDigitsScoreboardBest.get(spriteLast).setCurrentTileIndex(ndig);
|
||||
spriteLast++;
|
||||
}
|
||||
while(spriteLast < scoreDigitsScoreboardBest.size()) {
|
||||
if(showDigits) scoreDigitsScoreboardBest.get(spriteLast).setAlpha(0f);
|
||||
spriteLast++;
|
||||
}
|
||||
}
|
||||
|
||||
public void setScoreMain(Integer score){
|
||||
String str = score + "";
|
||||
int spriteLast = scoreDigitsMain.size() - 1;
|
||||
for(int i = str.length() - 1; i >= 0; i--){
|
||||
int ndig = Integer.parseInt(str.charAt(i) + "");
|
||||
scoreDigitsMain.get(spriteLast).setAlpha(1f);
|
||||
scoreDigitsMain.get(spriteLast).setCurrentTileIndex(ndig);
|
||||
spriteLast--;
|
||||
}
|
||||
while(spriteLast >= 0) {
|
||||
scoreDigitsMain.get(spriteLast).setAlpha(0f);
|
||||
spriteLast--;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetGame(){
|
||||
clearCrystalObstacles();
|
||||
mScoreLabelMainSprite.setAlpha(0f);
|
||||
Hoppy_Girl.currentState = Hoppy_Girl.GAMESTATE.READY;
|
||||
mPlayer.reset();
|
||||
hideGameOver();
|
||||
hideScoreMain();
|
||||
gameScore = 0;
|
||||
FLOOR_VELOCITY = 5f;
|
||||
}
|
||||
|
||||
private void hideGameOver(){
|
||||
unregisterTouchArea(mReplayButtonSprite);
|
||||
unregisterTouchArea(mLeaderboardButtonSprite);
|
||||
sortChildren();
|
||||
//show white cover
|
||||
((Hoppy_Girl)mActivity).hideAds();
|
||||
hideScoreboardScores();
|
||||
stopCrownIconFlash();
|
||||
mLeaderboardButtonSprite.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f));
|
||||
mReplayButtonSprite.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f));
|
||||
mGameoverSprite.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
crashCover.registerEntityModifier(new AlphaModifier(0.2f, 1f, 0f));
|
||||
mGetReadySprite.registerEntityModifier(new AlphaModifier(0.3f, 0f, 1f));
|
||||
gameoverShown = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
TimerHandler flashUpdateTimer;
|
||||
private void flashCrownIcon(){
|
||||
flashUpdateTimer = new TimerHandler(0.5f, new ITimerCallback() {
|
||||
@Override
|
||||
public void onTimePassed(TimerHandler pTimerHandler) {
|
||||
if(mCrownSprite.getAlpha() == 0f) mCrownSprite.setAlpha(1f);
|
||||
else mCrownSprite.setAlpha(0f);
|
||||
pTimerHandler.reset();
|
||||
}
|
||||
});
|
||||
mCrownSprite.registerUpdateHandler(flashUpdateTimer);
|
||||
}
|
||||
|
||||
private void stopCrownIconFlash(){
|
||||
if(flashUpdateTimer != null) mCrownSprite.unregisterUpdateHandler(flashUpdateTimer);
|
||||
mCrownSprite.setAlpha(0f);
|
||||
flashUpdateTimer = null;
|
||||
}
|
||||
|
||||
private void setGameOver(){
|
||||
crashCover.setZIndex(101);
|
||||
sortChildren();
|
||||
//show white cover
|
||||
crashCover.registerEntityModifier(new AlphaModifier(0.4f, 0.0f, 1f){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
mGameoverSprite.registerEntityModifier(new AlphaModifier(0.4f, 0.0f, 1f));
|
||||
mLeaderboardButtonSprite.registerEntityModifier(new AlphaModifier(0.4f, 0.0f, 0.3f));
|
||||
mReplayButtonSprite.registerEntityModifier(new AlphaModifier(0.4f, 0.0f, 1f));
|
||||
gameoverShown = true;
|
||||
((Hoppy_Girl)mActivity).showAds();
|
||||
|
||||
Hoppy_Girl mGame = (Hoppy_Girl)mActivity;
|
||||
int HS = mGame.getBestScore();
|
||||
if(gameScore > HS){
|
||||
mGame.saveBestScore(gameScore);
|
||||
flashCrownIcon();
|
||||
}
|
||||
setScoreboardScore(gameScore, false);
|
||||
setScoreboardBestScore(mGame.getBestScore(), false);
|
||||
|
||||
showScoreboardScores();
|
||||
registerTouchArea(mReplayButtonSprite);
|
||||
registerTouchArea(mLeaderboardButtonSprite);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void flashWhite(){
|
||||
AlphaModifier flashin = new AlphaModifier(0.07f, 0f, 1f);
|
||||
DelayModifier flashpause = new DelayModifier(0.02f);
|
||||
AlphaModifier flashout = new AlphaModifier(0.07f, 1f, 0f);
|
||||
sortChildren();
|
||||
//crashCover.registerEntityModifier(flashin);
|
||||
crashCover.registerEntityModifier(new SequenceEntityModifier(flashin, flashpause, flashout));
|
||||
}
|
||||
|
||||
private float getLastCloudRight(){
|
||||
if(lstClouds.size() == 0) return 0f;
|
||||
CloudsBG lastC = lstClouds.get(lstClouds.size() - 1);
|
||||
return lastC.getX() + lastC.getW();
|
||||
}
|
||||
|
||||
private float getLastFloorRight(){
|
||||
if(lstFloors.size() == 0) return 0f;
|
||||
Floor lastF = lstFloors.get(lstFloors.size() - 1);
|
||||
return lastF.getSpriteX() + lastF.getSpriteW();
|
||||
}
|
||||
|
||||
private void moveClouds(){
|
||||
for(CloudsBG cld : lstClouds){
|
||||
cld.setX(cld.getX() - CLOUD_VELOCITY);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveFloors(){
|
||||
for(Floor flr : lstFloors){
|
||||
flr.setSpriteX(flr.getSpriteX() - FLOOR_VELOCITY);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeOffscreenFloor(){
|
||||
if(lstFloors.size() > 0){
|
||||
if(lstFloors.get(0).getSpriteX() < -90f){
|
||||
detachChild(lstFloors.get(0).getFloorSprite());
|
||||
lstFloors.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeOffscreenCloud(){
|
||||
if(lstClouds.size() > 0){
|
||||
if(lstClouds.get(0).getX() < -480f){
|
||||
detachChild(lstClouds.get(0).getSprite());
|
||||
lstClouds.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addCloud(){
|
||||
CloudsBG cld = new CloudsBG(mCloudRegion, mEngine);
|
||||
cld.attachSprite(this, getLastCloudRight() + 150f, CLOUD_Y);
|
||||
cld.getSprite().setZIndex(0);
|
||||
lstClouds.add(cld);
|
||||
sortChildren();
|
||||
}
|
||||
|
||||
private void addFloor(){
|
||||
Floor flr = new Floor(mFloorRegion, mEngine);
|
||||
flr.attachSprite(this, getLastFloorRight(), FLOOR_Y);
|
||||
flr.getFloorSprite().setZIndex(0);
|
||||
lstFloors.add(flr);
|
||||
sortChildren();
|
||||
}
|
||||
|
||||
private void setNextCrystalObstacleInterval(){
|
||||
int randInterval = (int)(Math.floor(Math.random() * (crystalObstacleIntervals.length)));
|
||||
crystalObstacleCurrentInterval = crystalObstacleIntervals[randInterval];
|
||||
}
|
||||
|
||||
private void moveCrystalObstacles(){
|
||||
for(CrystalObstacles obs : lstCrystalO)
|
||||
obs.setX(obs.getX() - FLOOR_VELOCITY);
|
||||
}
|
||||
|
||||
private void removeOffscreenCrystalObstacles(){
|
||||
if(lstCrystalO.size() == 0) return;
|
||||
CrystalObstacles obs = lstCrystalO.get(0);
|
||||
if(obs.getX() < - 50f){
|
||||
obs.disposeObject(this);
|
||||
lstCrystalO.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearCrystalObstacles(){
|
||||
for(CrystalObstacles crys : lstCrystalO){
|
||||
detachChild(crys.getSprite());
|
||||
}
|
||||
lstCrystalO.clear();
|
||||
}
|
||||
|
||||
private void spawnCrystalObstacle(){
|
||||
CrystalObstacles obs = new CrystalObstacles(mCrystal1Region, mCrystal2Region, mCrystal3Region, mEngine);
|
||||
int randType = (int)(Math.floor(Math.random() * 3));
|
||||
obs.attachCrystal(this, mCamera.getWidth() + 50f, FLOOR_Y, randType);
|
||||
obs.getSprite().setZIndex(2);
|
||||
lstCrystalO.add(obs);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,198 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.content.Context;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import org.andengine.engine.camera.Camera;
|
||||
import org.andengine.engine.options.EngineOptions;
|
||||
import org.andengine.engine.options.ScreenOrientation;
|
||||
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
|
||||
import org.andengine.engine.options.resolutionpolicy.FixedResolutionPolicy;
|
||||
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
|
||||
import org.andengine.engine.options.resolutionpolicy.RelativeResolutionPolicy;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.scene.background.Background;
|
||||
import org.andengine.entity.util.FPSLogger;
|
||||
import org.andengine.opengl.view.RenderSurfaceView;
|
||||
import org.andengine.ui.activity.SimpleBaseGameActivity;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdSize;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
import org.andengine.util.debug.Debug;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class Hoppy_Girl extends SimpleBaseGameActivity {
|
||||
|
||||
//Best score
|
||||
static int BESTSCORE = 0;
|
||||
|
||||
//Objects
|
||||
private Camera camera;
|
||||
|
||||
//AdView
|
||||
public AdView myAd;
|
||||
|
||||
//Screens
|
||||
SplashScreen splash;
|
||||
StartScreen sStart;
|
||||
GameScreen sGame;
|
||||
|
||||
//Current game state
|
||||
public static GAMESTATE currentState = GAMESTATE.SPLASH;
|
||||
|
||||
//Game states
|
||||
public static enum GAMESTATE{
|
||||
SPLASH,
|
||||
START,
|
||||
READY,
|
||||
RUNNING,
|
||||
GAMEOVER,
|
||||
PAUSED
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSetContentView(){
|
||||
mRenderSurfaceView = new RenderSurfaceView(this);
|
||||
mRenderSurfaceView.setRenderer(mEngine, this);
|
||||
AdRequest adreq = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
|
||||
.addTestDevice("CC5F2C72DF2B356BBF0DA198")
|
||||
.build();
|
||||
|
||||
final FrameLayout frameLayout = new FrameLayout(this);
|
||||
final FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
||||
final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL);
|
||||
|
||||
myAd = new AdView(this);
|
||||
myAd.setAdSize(AdSize.BANNER);
|
||||
myAd.setAdUnitId(getResources().getString(R.string.ad_unit_id));
|
||||
myAd.loadAd(adreq);
|
||||
myAd.setVisibility(View.INVISIBLE);
|
||||
|
||||
frameLayout.addView(mRenderSurfaceView, super.createSurfaceViewLayoutParams());
|
||||
frameLayout.addView(myAd, adViewLayoutParams);
|
||||
|
||||
setContentView(frameLayout, frameLayoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EngineOptions onCreateEngineOptions() {
|
||||
|
||||
//Compute camera size by aspect ratio.
|
||||
//Pick some value for your height.
|
||||
float cameraHeight = 380;
|
||||
|
||||
//Get the display metrics object.
|
||||
final DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||
|
||||
//Populate it with data about your display.
|
||||
this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
|
||||
//Calculate the aspect ratio of the device.
|
||||
float aspectRatio = (float) displayMetrics.widthPixels / (float) displayMetrics.heightPixels;
|
||||
|
||||
//Multiply the aspect ratio by the fixed height.
|
||||
float cameraWidth = Math.round(aspectRatio * cameraHeight);
|
||||
|
||||
//Create the camera using those values.
|
||||
camera = new Camera(0, 0, cameraWidth, cameraHeight);
|
||||
|
||||
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), camera);
|
||||
engineOptions.getAudioOptions().setNeedsSound(true);
|
||||
return engineOptions;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateResources(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Scene onCreateScene(){
|
||||
//Retrieve best score.
|
||||
retrieveBestScore();
|
||||
|
||||
//Start on splash screen.
|
||||
splash = new SplashScreen(this, this.getTextureManager(), mEngine, camera);
|
||||
return splash;
|
||||
}
|
||||
|
||||
public int getBestScore(){
|
||||
return BESTSCORE;
|
||||
}
|
||||
|
||||
public void saveBestScore(int newbest){
|
||||
BESTSCORE = newbest;
|
||||
String bs = new Integer(BESTSCORE).toString();
|
||||
try {
|
||||
FileOutputStream fout = openFileOutput("hoppygirl_data", Context.MODE_PRIVATE);
|
||||
fout.write(bs.getBytes());
|
||||
fout.close();
|
||||
} catch(Exception ex){
|
||||
Debug.e(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void retrieveBestScore(){
|
||||
try {
|
||||
if (getApplicationContext().getFileStreamPath("hoppygirl_data") != null) {
|
||||
FileInputStream finp = openFileInput("hoppygirl_data");
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(finp));
|
||||
String ln = rd.readLine();
|
||||
if (ln != null) {
|
||||
BESTSCORE = Integer.parseInt(ln);
|
||||
}
|
||||
rd.close();
|
||||
finp.close();
|
||||
} else {
|
||||
String bs = new Integer(0).toString();
|
||||
FileOutputStream fout = openFileOutput("hoppygirl_data", Context.MODE_PRIVATE);
|
||||
fout.write(bs.getBytes());
|
||||
fout.close();
|
||||
}
|
||||
}catch(Exception e){
|
||||
Debug.e(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setGameOnStarting(){
|
||||
Hoppy_Girl.currentState = GAMESTATE.START;
|
||||
sStart = new StartScreen(this, getTextureManager(), mEngine, camera);
|
||||
mEngine.setScene(sStart);
|
||||
}
|
||||
|
||||
public void hideAds(){
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myAd.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showAds(){
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myAd.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setGameonGameScene(){
|
||||
Hoppy_Girl.currentState = Hoppy_Girl.GAMESTATE.READY;
|
||||
sGame = new GameScreen(this, getTextureManager(), mEngine, camera);
|
||||
mEngine.setScene(sGame);
|
||||
}
|
||||
|
||||
public static float getClr(int colorval){
|
||||
return (float)colorval / 255f;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.audio.sound.Sound;
|
||||
import org.andengine.audio.sound.SoundFactory;
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.engine.camera.Camera;
|
||||
import org.andengine.entity.IEntity;
|
||||
import org.andengine.entity.primitive.Rectangle;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.shape.IShape;
|
||||
import org.andengine.entity.sprite.AnimatedSprite;
|
||||
import org.andengine.opengl.texture.TextureManager;
|
||||
import org.andengine.opengl.texture.TextureOptions;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BuildableBitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource;
|
||||
import org.andengine.opengl.texture.atlas.buildable.builder.BlackPawnTextureAtlasBuilder;
|
||||
import org.andengine.opengl.texture.atlas.buildable.builder.ITextureAtlasBuilder;
|
||||
import org.andengine.opengl.texture.region.TiledTextureRegion;
|
||||
import org.andengine.ui.activity.BaseGameActivity;
|
||||
import org.andengine.util.debug.Debug;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 27, 2014
|
||||
*
|
||||
*/
|
||||
|
||||
public class Player{
|
||||
|
||||
BuildableBitmapTextureAtlas bmpAtlas;
|
||||
|
||||
TiledTextureRegion playerRegion;
|
||||
AnimatedSprite playerSprite;
|
||||
|
||||
Engine mEngine;
|
||||
|
||||
Sound jumpSound;
|
||||
Sound hitSound;
|
||||
|
||||
float VERTICAL_SPEED = 0.0f;
|
||||
float FALLING_CONSTANT = -2000f;
|
||||
float FLOOR_Y_LIMIT = 0.0f;
|
||||
final float JUMP_CONSTANT = -750f;
|
||||
final float JUMP2_CONSTANT = -650f;
|
||||
|
||||
Rectangle areaBody;
|
||||
Rectangle areaHead;
|
||||
|
||||
public PLAYERSTATE mystate = PLAYERSTATE.RUNNING;
|
||||
int JUMPFRAME = 0;
|
||||
|
||||
public enum PLAYERSTATE{
|
||||
RUNNING,
|
||||
JUMPING,
|
||||
DOUBLEJUMP,
|
||||
DEAD,
|
||||
}
|
||||
|
||||
public Player(BaseGameActivity actv, TextureManager tmgr, Engine ngn){
|
||||
//Get engine.
|
||||
mEngine = ngn;
|
||||
|
||||
//Prepare texture.
|
||||
bmpAtlas = new BuildableBitmapTextureAtlas(tmgr, 1050, 120, TextureOptions.NEAREST_PREMULTIPLYALPHA);
|
||||
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
|
||||
playerRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(bmpAtlas, actv, "player_tiled.png", 14, 1);
|
||||
|
||||
//Build Atlas.
|
||||
try {
|
||||
bmpAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 1));
|
||||
bmpAtlas.load();
|
||||
} catch(ITextureAtlasBuilder.TextureAtlasBuilderException e){
|
||||
Debug.e(e);
|
||||
}
|
||||
|
||||
//Load sprite.
|
||||
setupSprite();
|
||||
|
||||
//-------------- SOUND ASSETS-------------------------
|
||||
SoundFactory.setAssetBasePath("sfx/");
|
||||
try {
|
||||
jumpSound = SoundFactory.createSoundFromAsset(actv.getSoundManager(), actv, "jumpsound.wav");
|
||||
jumpSound.setVolume(0.3f);
|
||||
|
||||
hitSound = SoundFactory.createSoundFromAsset(actv.getSoundManager(), actv, "hitsound.wav");
|
||||
hitSound.setVolume(0.5f);
|
||||
} catch (Exception ex){
|
||||
Debug.e(ex);
|
||||
}
|
||||
|
||||
//Setup collision areas
|
||||
areaHead = new Rectangle(playerSprite.getX() + 6, playerSprite.getY() + 10, 52, 54, mEngine.getVertexBufferObjectManager());
|
||||
areaBody = new Rectangle(playerSprite.getX() + 13, playerSprite.getY() + 63, 31, 52, mEngine.getVertexBufferObjectManager());
|
||||
|
||||
}
|
||||
|
||||
public boolean playerCollidesWith(IShape entity){
|
||||
if(entity.collidesWith(areaHead))
|
||||
return true;
|
||||
if(entity.collidesWith(areaBody))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean playerCollidesWith(Rectangle[] rects){
|
||||
for(Rectangle rect : rects) {
|
||||
if (rect.collidesWith(areaHead))
|
||||
return true;
|
||||
if (rect.collidesWith(areaBody))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setFloorLimit(float ylimit){
|
||||
FLOOR_Y_LIMIT = ylimit;
|
||||
}
|
||||
|
||||
public void update(float mElapsedTime){
|
||||
|
||||
playerSprite.setZIndex(5);
|
||||
|
||||
float nVal = playerSprite.getY() + (VERTICAL_SPEED * mElapsedTime);
|
||||
if(nVal <= FLOOR_Y_LIMIT)
|
||||
playerSprite.setY(nVal);
|
||||
else {
|
||||
playerSprite.setY(FLOOR_Y_LIMIT);
|
||||
if(mystate == PLAYERSTATE.JUMPING || mystate == PLAYERSTATE.DOUBLEJUMP) {
|
||||
mystate = PLAYERSTATE.RUNNING;
|
||||
playerSprite.stopAnimation();
|
||||
playerSprite.animate(new long[]{160, 160, 160, 160}, 0, 3, true);
|
||||
}
|
||||
}
|
||||
VERTICAL_SPEED -= FALLING_CONSTANT * mElapsedTime;
|
||||
|
||||
//Update collsion areas
|
||||
//Setup collision areas
|
||||
areaHead.setPosition(playerSprite.getX() + 17, playerSprite.getY() + 10);
|
||||
areaBody.setPosition(playerSprite.getX() + 22, playerSprite.getY() + 63);
|
||||
|
||||
//Set jump animation.
|
||||
if(mystate == PLAYERSTATE.JUMPING || mystate == PLAYERSTATE.DOUBLEJUMP){
|
||||
if((VERTICAL_SPEED > (3 * JUMP_CONSTANT / 4f)) && JUMPFRAME == 0){
|
||||
playerSprite.stopAnimation();
|
||||
playerSprite.animate(new long[]{5000, 5000}, 4, 5, true);
|
||||
JUMPFRAME = 1;
|
||||
}
|
||||
if((VERTICAL_SPEED > (JUMP_CONSTANT / 2f)) && JUMPFRAME == 1){
|
||||
playerSprite.stopAnimation();
|
||||
playerSprite.animate(new long[]{5000, 5000}, 5, 6, true);
|
||||
JUMPFRAME = 2;
|
||||
}
|
||||
if(VERTICAL_SPEED < 50f && JUMPFRAME == 2){
|
||||
playerSprite.stopAnimation();
|
||||
playerSprite.animate(new long[]{5000, 5000}, 6, 7, true);
|
||||
JUMPFRAME = 3;
|
||||
}
|
||||
if(VERTICAL_SPEED < -50f && JUMPFRAME == 3){
|
||||
playerSprite.stopAnimation();
|
||||
playerSprite.animate(new long[]{200, 150, 5000}, 7, 9, true);
|
||||
JUMPFRAME = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void jump(){
|
||||
if(mystate == PLAYERSTATE.RUNNING) {
|
||||
VERTICAL_SPEED = JUMP_CONSTANT;
|
||||
mystate = PLAYERSTATE.JUMPING;
|
||||
jumpSound.play();
|
||||
} else if (mystate == PLAYERSTATE.JUMPING){
|
||||
//initiate double jump.
|
||||
mystate = PLAYERSTATE.DOUBLEJUMP;
|
||||
VERTICAL_SPEED = JUMP2_CONSTANT;
|
||||
jumpSound.play();
|
||||
}
|
||||
JUMPFRAME = 0;
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
setRunning();
|
||||
JUMPFRAME = 0;
|
||||
}
|
||||
|
||||
private void setRunning(){
|
||||
mystate = PLAYERSTATE.RUNNING;
|
||||
playerSprite.animate(new long[]{160, 160, 160, 160}, 0, 3, true);
|
||||
}
|
||||
|
||||
public void die(){
|
||||
mystate = PLAYERSTATE.DEAD;
|
||||
VERTICAL_SPEED = -300f;
|
||||
playerSprite.animate(new long[]{400, 200}, 10, 11, false, new AnimatedSprite.IAnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStarted(AnimatedSprite pAnimatedSprite, int pInitialLoopCount) {}
|
||||
@Override
|
||||
public void onAnimationFrameChanged(AnimatedSprite pAnimatedSprite, int pOldFrameIndex, int pNewFrameIndex) {}
|
||||
@Override
|
||||
public void onAnimationLoopFinished(AnimatedSprite pAnimatedSprite, int pRemainingLoopCount, int pInitialLoopCount) {}
|
||||
|
||||
@Override
|
||||
public void onAnimationFinished(AnimatedSprite pAnimatedSprite) {
|
||||
playerSprite.animate(new long[]{250, 250}, 12, 13, true);
|
||||
}
|
||||
});
|
||||
hitSound.play();
|
||||
}
|
||||
|
||||
public void attachPlayerSprite(Scene scn){
|
||||
scn.attachChild(playerSprite);
|
||||
}
|
||||
|
||||
public AnimatedSprite getPlayerSprite(){
|
||||
return playerSprite;
|
||||
}
|
||||
|
||||
private void setupSprite(){
|
||||
playerSprite = new AnimatedSprite(0, 0, playerRegion, mEngine.getVertexBufferObjectManager());
|
||||
setRunning();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.engine.camera.Camera;
|
||||
import org.andengine.engine.handler.timer.ITimerCallback;
|
||||
import org.andengine.engine.handler.timer.TimerHandler;
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.entity.IEntity;
|
||||
import org.andengine.entity.modifier.AlphaModifier;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.scene.background.Background;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.opengl.texture.TextureManager;
|
||||
import org.andengine.opengl.texture.TextureOptions;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
import org.andengine.opengl.util.GLState;
|
||||
import org.andengine.ui.activity.SimpleBaseGameActivity;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
|
||||
|
||||
/**
|
||||
* Created by John Espiritu on 12/25/2014.
|
||||
*/
|
||||
|
||||
public class SplashScreen extends Scene{
|
||||
|
||||
//Splash Logo
|
||||
BitmapTextureAtlas splashatlas;
|
||||
ITextureRegion splashRegion;
|
||||
|
||||
//Fade cover
|
||||
BitmapTextureAtlas coveratlas;
|
||||
ITextureRegion coverRegion;
|
||||
|
||||
Sprite cover;
|
||||
Sprite splash;
|
||||
Engine mEngine;
|
||||
Camera mCamera;
|
||||
|
||||
//Constructor
|
||||
public SplashScreen(final SimpleBaseGameActivity actvt, TextureManager tmgr, Engine engn, Camera cm){
|
||||
super(); //Superclass init.
|
||||
mEngine = engn; //Game Engine
|
||||
mCamera = cm; //Camera
|
||||
|
||||
//Setup texture atlas base path.
|
||||
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
|
||||
|
||||
//Initialize splash logo
|
||||
splashatlas = new BitmapTextureAtlas(tmgr, 111, 54, TextureOptions.NEAREST);
|
||||
splashRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashatlas, actvt, "splash_logo.png", 0, 0);
|
||||
splashatlas.load();
|
||||
|
||||
//Initialize cover sprite.
|
||||
coveratlas = new BitmapTextureAtlas(tmgr, 2, 2, TextureOptions.NEAREST);
|
||||
coverRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(coveratlas, actvt, "black_bg.png", 0, 0);
|
||||
coveratlas.load();
|
||||
|
||||
//Setup screen.
|
||||
setBackground(new Background(Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237)));
|
||||
setupContents();
|
||||
|
||||
//Splash animation: fade in and out and unload.
|
||||
cover.registerEntityModifier(new AlphaModifier(0.5f, 1.0f, 0.0f){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
mEngine.registerUpdateHandler(new TimerHandler(2f, new ITimerCallback() {
|
||||
@Override
|
||||
public void onTimePassed(TimerHandler pTimerHandler) {
|
||||
mEngine.unregisterUpdateHandler(pTimerHandler);
|
||||
cover.registerEntityModifier(new AlphaModifier(0.5f, 0.0f, 1.0f){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
mEngine.registerUpdateHandler(new TimerHandler(0.5f, new ITimerCallback() {
|
||||
@Override
|
||||
public void onTimePassed(TimerHandler pTimerHandler) {
|
||||
mEngine.unregisterUpdateHandler(pTimerHandler);
|
||||
//Dispose elements.
|
||||
detachChildren();
|
||||
((Hoppy_Girl)actvt).setGameOnStarting();
|
||||
disposeScene();
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void disposeScene(){
|
||||
if(isDisposed() == false){dispose();}
|
||||
}
|
||||
|
||||
private void setupContents(){
|
||||
//Splash logo
|
||||
splash = new Sprite(0, 0, splashRegion, mEngine.getVertexBufferObjectManager()) {
|
||||
@Override
|
||||
protected void preDraw(GLState pGLState, Camera pCamera){
|
||||
super.preDraw(pGLState, pCamera);
|
||||
pGLState.enableDither();
|
||||
}
|
||||
};
|
||||
splash.setPosition((mCamera.getWidth() - splash.getWidth()) * 0.5f, (mCamera.getHeight() - splash.getHeight()) * 0.5f);
|
||||
|
||||
cover = new Sprite(0, 0, coverRegion, mEngine.getVertexBufferObjectManager());
|
||||
cover.setSize(mCamera.getWidth(), mCamera.getHeight());
|
||||
cover.setZIndex(99);
|
||||
|
||||
//Attach sprites
|
||||
attachChild(splash);
|
||||
attachChild(cover);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,279 @@
|
|||
package com.hkri.HoppyGirl;
|
||||
|
||||
import org.andengine.engine.camera.Camera;
|
||||
import org.andengine.engine.Engine;
|
||||
import org.andengine.entity.IEntity;
|
||||
import org.andengine.entity.modifier.AlphaModifier;
|
||||
import org.andengine.entity.modifier.DelayModifier;
|
||||
import org.andengine.entity.modifier.MoveYModifier;
|
||||
import org.andengine.entity.modifier.SequenceEntityModifier;
|
||||
import org.andengine.entity.scene.IOnSceneTouchListener;
|
||||
import org.andengine.entity.scene.Scene;
|
||||
import org.andengine.entity.scene.background.Background;
|
||||
import org.andengine.entity.sprite.Sprite;
|
||||
import org.andengine.input.touch.TouchEvent;
|
||||
import org.andengine.opengl.texture.TextureManager;
|
||||
import org.andengine.opengl.texture.TextureOptions;
|
||||
import org.andengine.opengl.texture.region.ITextureRegion;
|
||||
import org.andengine.ui.activity.SimpleBaseGameActivity;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
|
||||
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* (c) 2014 John Espiritu
|
||||
* (c) 2014 hkri studios
|
||||
*
|
||||
* @author John Espiritu
|
||||
* @since December 26, 2014
|
||||
*
|
||||
*/
|
||||
public class StartScreen extends Scene implements IOnSceneTouchListener {
|
||||
|
||||
//Floor variables
|
||||
BitmapTextureAtlas bmpAtlas;
|
||||
ITextureRegion floorRegion;
|
||||
float FLOOR_Y = 0.0f;
|
||||
float FLOOR_VELOCITY = 4f;
|
||||
|
||||
//Cloud bg variables
|
||||
ITextureRegion cloudsRegion;
|
||||
float CLOUD_VELOCITY = 1f;
|
||||
float CLOUD_Y = 40f;
|
||||
|
||||
//Tap to start variable
|
||||
ITextureRegion instructionRegion;
|
||||
Sprite mInstructionTap;
|
||||
|
||||
//Title variable
|
||||
ITextureRegion titleRegion;
|
||||
Sprite mGameTitle;
|
||||
|
||||
//Cover
|
||||
BitmapTextureAtlas coveratlas;
|
||||
ITextureRegion coverRegion;
|
||||
Sprite cover;
|
||||
|
||||
//Game properties
|
||||
Engine mEngine;
|
||||
Camera mCamera;
|
||||
TextureManager mTManager;
|
||||
SimpleBaseGameActivity mActivity;
|
||||
|
||||
//Intro contents
|
||||
Player mPlayer;
|
||||
|
||||
Floor mFloor;
|
||||
CloudsBG mCloud;
|
||||
|
||||
ArrayList<Floor> lstFloors = new ArrayList<Floor>();
|
||||
ArrayList<CloudsBG> lstClouds = new ArrayList<CloudsBG>();
|
||||
|
||||
public StartScreen(final SimpleBaseGameActivity actvt, TextureManager tmgr, Engine engn, Camera cm){
|
||||
super(); //Superclass init.
|
||||
mActivity = actvt;
|
||||
mEngine = engn; //Game Engine
|
||||
mCamera = cm; //Camera
|
||||
mTManager = tmgr; //Texture manager.
|
||||
|
||||
//Register touch handler
|
||||
setOnSceneTouchListener(this);
|
||||
|
||||
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
|
||||
|
||||
//Setup contents
|
||||
setupContents();
|
||||
|
||||
//Fade in animation.
|
||||
cover.registerEntityModifier(new AlphaModifier(0.3f, 1.0f, 0.0f));
|
||||
|
||||
//Set scene.
|
||||
setBackground(new Background(Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237), Hoppy_Girl.getClr(237)));
|
||||
|
||||
//Add player
|
||||
addPlayer();
|
||||
|
||||
//Add clouds bg
|
||||
addCloud();
|
||||
|
||||
//Add floor sprite
|
||||
FLOOR_Y = (mPlayer.getPlayerSprite().getY() + mPlayer.getPlayerSprite().getHeight());
|
||||
|
||||
while(getLastFloorRight() < mCamera.getWidth() + 50f) {
|
||||
addFloor();
|
||||
}
|
||||
|
||||
//title sprite
|
||||
float titleW = 429f, titleH = 102f;
|
||||
mGameTitle = new Sprite((mCamera.getWidth() - titleW) * 0.5f, 60f, titleRegion, mEngine.getVertexBufferObjectManager());
|
||||
mGameTitle.setSize(titleW, titleH);
|
||||
|
||||
MoveYModifier modTitleYDown = new MoveYModifier(0.4f, 60f, 65f);
|
||||
MoveYModifier modTitleYUp = new MoveYModifier(0.4f, 65f, 60f);
|
||||
SequenceEntityModifier modTitleFloat = new SequenceEntityModifier(modTitleYDown, modTitleYUp){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
super.reset();
|
||||
}
|
||||
};
|
||||
mGameTitle.registerEntityModifier(modTitleFloat);
|
||||
mGameTitle.setZIndex(2);
|
||||
|
||||
//Add tap to start sprite.
|
||||
mInstructionTap = new Sprite((mCamera.getWidth() - instructionRegion.getWidth()) * 0.5f, mCamera.getHeight() - 70f, instructionRegion, mEngine.getVertexBufferObjectManager());
|
||||
mInstructionTap.setZIndex(2);
|
||||
AlphaModifier insDisappear = new AlphaModifier(0.01f, 1f, 0f);
|
||||
AlphaModifier insAppear = new AlphaModifier(0.01f, 0f, 1f);
|
||||
DelayModifier insDelay = new DelayModifier(0.7f);
|
||||
DelayModifier insDelay2 = new DelayModifier(0.7f);
|
||||
SequenceEntityModifier modInstructionflash = new SequenceEntityModifier(insDisappear, insDelay, insAppear, insDelay2){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
super.reset();
|
||||
}
|
||||
};
|
||||
mInstructionTap.registerEntityModifier(modInstructionflash);
|
||||
|
||||
attachChild(mInstructionTap);
|
||||
attachChild(mGameTitle);
|
||||
}
|
||||
|
||||
private void setupContents(){
|
||||
//Floor resources
|
||||
bmpAtlas = new BitmapTextureAtlas(mTManager, 670, 470, TextureOptions.NEAREST);
|
||||
floorRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "floor_tile.png", 0, 0);
|
||||
|
||||
//Cloud resources
|
||||
cloudsRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "clouds_bg.png", 0, 89);
|
||||
|
||||
//Title resources
|
||||
titleRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "Hoppy_girl_gamelogo.png", 0, 260);
|
||||
|
||||
//Tap to start resources
|
||||
instructionRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(bmpAtlas, mActivity, "tap_to_start.png", 0, 417);
|
||||
|
||||
//Load bmp atlas.
|
||||
bmpAtlas.load();
|
||||
|
||||
//Initialize cover resources.
|
||||
coveratlas = new BitmapTextureAtlas(mTManager, 2, 2, TextureOptions.NEAREST);
|
||||
coverRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(coveratlas, mActivity, "black_bg.png", 0, 0);
|
||||
coveratlas.load();
|
||||
|
||||
//cover sprite
|
||||
cover = new Sprite(0, 0, coverRegion, mEngine.getVertexBufferObjectManager());
|
||||
cover.setSize(mCamera.getWidth(), mCamera.getHeight());
|
||||
cover.setZIndex(100);
|
||||
attachChild(cover);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onManagedUpdate(final float pSecondsElapsed){
|
||||
moveFloors();
|
||||
moveClouds();
|
||||
removeOffscreenFloors();
|
||||
removeOffscreenClouds();
|
||||
|
||||
if(getLastCloudRight() < mCamera.getWidth() + 50f)
|
||||
addCloud();
|
||||
|
||||
if(getLastFloorRight() < mCamera.getWidth() + 50f)
|
||||
addFloor();
|
||||
|
||||
super.onManagedUpdate(pSecondsElapsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSceneTouchEvent(Scene scn, final TouchEvent e){
|
||||
if(e.isActionDown()){
|
||||
//Fade out animation.
|
||||
cover.registerEntityModifier(new AlphaModifier(0.3f, 0.0f, 1f){
|
||||
@Override
|
||||
protected void onModifierFinished(IEntity pItem){
|
||||
//Unload scene.
|
||||
detachChildren();
|
||||
((Hoppy_Girl)mActivity).setGameonGameScene();
|
||||
disposeScene();
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void disposeScene(){
|
||||
if(isDisposed() == false){dispose();}
|
||||
}
|
||||
|
||||
private void removeOffscreenFloors(){
|
||||
if(lstFloors.size() > 0){
|
||||
if(lstFloors.get(0).getSpriteX() < -100f){
|
||||
detachChild(lstFloors.get(0).getFloorSprite());
|
||||
lstFloors.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeOffscreenClouds(){
|
||||
if(lstClouds.size() > 0){
|
||||
if(lstClouds.get(0).getX() < - 500f){
|
||||
detachChild(lstClouds.get(0).getSprite());
|
||||
lstClouds.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void moveFloors(){
|
||||
for(Floor flr : lstFloors){
|
||||
flr.setSpriteX(flr.getSpriteX() - FLOOR_VELOCITY);
|
||||
}
|
||||
}
|
||||
|
||||
private void moveClouds(){
|
||||
for(CloudsBG cld : lstClouds){
|
||||
cld.setX(cld.getX() - CLOUD_VELOCITY);
|
||||
}
|
||||
}
|
||||
|
||||
private float getLastFloorRight(){
|
||||
if(lstFloors.size() == 0)
|
||||
return 0;
|
||||
Floor lastFloor = lstFloors.get(lstFloors.size() - 1); //get last floor
|
||||
return lastFloor.getSpriteX() + lastFloor.getSpriteW();
|
||||
}
|
||||
|
||||
private float getLastCloudRight(){
|
||||
if(lstClouds.size() == 0)
|
||||
return 0;
|
||||
CloudsBG lastCloud = lstClouds.get(lstClouds.size() - 1); //get last cloud
|
||||
return lastCloud.getX() + lastCloud.getW();
|
||||
}
|
||||
|
||||
private void addFloor(){
|
||||
mFloor = new Floor(floorRegion, mEngine);
|
||||
mFloor.attachSprite(this, getLastFloorRight(), FLOOR_Y);
|
||||
mFloor.getFloorSprite().setZIndex(0);
|
||||
lstFloors.add(mFloor);
|
||||
sortChildren();
|
||||
}
|
||||
|
||||
private void addCloud(){
|
||||
//Setup cloud.
|
||||
mCloud = new CloudsBG(cloudsRegion, mEngine);
|
||||
mCloud.attachSprite(this, getLastCloudRight() + 150f, CLOUD_Y);
|
||||
mCloud.getSprite().setZIndex(0);
|
||||
lstClouds.add(mCloud);
|
||||
}
|
||||
|
||||
private void addPlayer(){
|
||||
//Setup player
|
||||
mPlayer = new Player(mActivity, mTManager, mEngine);
|
||||
mPlayer.attachPlayerSprite(this);
|
||||
|
||||
//Center sprite.
|
||||
mPlayer.getPlayerSprite().setPosition((mCamera.getWidth() - mPlayer.getPlayerSprite().getWidth()) * 0.5f, (mCamera.getHeight() - mPlayer.getPlayerSprite().getHeight()) * 0.5f + 55);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||