Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02e82c05ff | ||
|
|
f1892374b1 | ||
|
|
cfe631f701 | ||
|
|
04e712d7aa | ||
|
|
f23c11eb7d | ||
|
|
82024f82c2 | ||
|
|
774d72fab1 | ||
|
|
4abaed8982 | ||
|
|
58a708298c | ||
|
|
0a1020377b | ||
|
|
1feeb75883 | ||
|
|
ba1f705224 | ||
|
|
5ffbb6a4a5 | ||
|
|
3a65b804df | ||
|
|
c83775a756 | ||
|
|
9a00f4e61a | ||
|
|
2d8dc8022e | ||
|
|
3cca9c29f2 | ||
|
|
3cbc26b42d | ||
|
|
812308b869 | ||
|
|
f79361c06a | ||
|
|
915abd8853 | ||
|
|
adb19d7e82 | ||
|
|
a303e6afc6 | ||
|
|
e01836e91c | ||
|
|
1a34673859 | ||
|
|
a29b118488 | ||
|
|
36424e3465 | ||
|
|
53d03abf8e |
@@ -0,0 +1 @@
|
||||
/bin
|
||||
|
After Width: | Height: | Size: 246 KiB |
@@ -1,38 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="mangavalk.tetris"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="13"
|
||||
android:targetSdkVersion="19" />
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
<meta-data android:name="com.google.android.gms.version"
|
||||
android:value="@integer/google_play_services_version"/>
|
||||
|
||||
<activity
|
||||
android:name="mangavalk.tetris.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.google.android.gms.ads.AdActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,148 +0,0 @@
|
||||
int attr adSize 0x7f010000
|
||||
int attr adSizes 0x7f010001
|
||||
int attr adUnitId 0x7f010002
|
||||
int attr cameraBearing 0x7f010004
|
||||
int attr cameraTargetLat 0x7f010005
|
||||
int attr cameraTargetLng 0x7f010006
|
||||
int attr cameraTilt 0x7f010007
|
||||
int attr cameraZoom 0x7f010008
|
||||
int attr mapType 0x7f010003
|
||||
int attr uiCompass 0x7f010009
|
||||
int attr uiRotateGestures 0x7f01000a
|
||||
int attr uiScrollGestures 0x7f01000b
|
||||
int attr uiTiltGestures 0x7f01000c
|
||||
int attr uiZoomControls 0x7f01000d
|
||||
int attr uiZoomGestures 0x7f01000e
|
||||
int attr useViewLifecycle 0x7f01000f
|
||||
int attr zOrderOnTop 0x7f010010
|
||||
int color common_action_bar_splitter 0x7f040009
|
||||
int color common_signin_btn_dark_text_default 0x7f040000
|
||||
int color common_signin_btn_dark_text_disabled 0x7f040002
|
||||
int color common_signin_btn_dark_text_focused 0x7f040003
|
||||
int color common_signin_btn_dark_text_pressed 0x7f040001
|
||||
int color common_signin_btn_default_background 0x7f040008
|
||||
int color common_signin_btn_light_text_default 0x7f040004
|
||||
int color common_signin_btn_light_text_disabled 0x7f040006
|
||||
int color common_signin_btn_light_text_focused 0x7f040007
|
||||
int color common_signin_btn_light_text_pressed 0x7f040005
|
||||
int color common_signin_btn_text_dark 0x7f04000a
|
||||
int color common_signin_btn_text_light 0x7f04000b
|
||||
int dimen activity_horizontal_margin 0x7f080000
|
||||
int dimen activity_vertical_margin 0x7f080001
|
||||
int drawable common_signin_btn_icon_dark 0x7f020000
|
||||
int drawable common_signin_btn_icon_disabled_dark 0x7f020001
|
||||
int drawable common_signin_btn_icon_disabled_focus_dark 0x7f020002
|
||||
int drawable common_signin_btn_icon_disabled_focus_light 0x7f020003
|
||||
int drawable common_signin_btn_icon_disabled_light 0x7f020004
|
||||
int drawable common_signin_btn_icon_focus_dark 0x7f020005
|
||||
int drawable common_signin_btn_icon_focus_light 0x7f020006
|
||||
int drawable common_signin_btn_icon_light 0x7f020007
|
||||
int drawable common_signin_btn_icon_normal_dark 0x7f020008
|
||||
int drawable common_signin_btn_icon_normal_light 0x7f020009
|
||||
int drawable common_signin_btn_icon_pressed_dark 0x7f02000a
|
||||
int drawable common_signin_btn_icon_pressed_light 0x7f02000b
|
||||
int drawable common_signin_btn_text_dark 0x7f02000c
|
||||
int drawable common_signin_btn_text_disabled_dark 0x7f02000d
|
||||
int drawable common_signin_btn_text_disabled_focus_dark 0x7f02000e
|
||||
int drawable common_signin_btn_text_disabled_focus_light 0x7f02000f
|
||||
int drawable common_signin_btn_text_disabled_light 0x7f020010
|
||||
int drawable common_signin_btn_text_focus_dark 0x7f020011
|
||||
int drawable common_signin_btn_text_focus_light 0x7f020012
|
||||
int drawable common_signin_btn_text_light 0x7f020013
|
||||
int drawable common_signin_btn_text_normal_dark 0x7f020014
|
||||
int drawable common_signin_btn_text_normal_light 0x7f020015
|
||||
int drawable common_signin_btn_text_pressed_dark 0x7f020016
|
||||
int drawable common_signin_btn_text_pressed_light 0x7f020017
|
||||
int drawable f0 0x7f020018
|
||||
int drawable f1 0x7f020019
|
||||
int drawable f2 0x7f02001a
|
||||
int drawable f3 0x7f02001b
|
||||
int drawable f4 0x7f02001c
|
||||
int drawable f5 0x7f02001d
|
||||
int drawable f6 0x7f02001e
|
||||
int drawable f7 0x7f02001f
|
||||
int drawable f8 0x7f020020
|
||||
int drawable f9 0x7f020021
|
||||
int drawable ic_launcher 0x7f020022
|
||||
int drawable ic_plusone_medium_off_client 0x7f020023
|
||||
int drawable ic_plusone_small_off_client 0x7f020024
|
||||
int drawable ic_plusone_standard_off_client 0x7f020025
|
||||
int drawable ic_plusone_tall_off_client 0x7f020026
|
||||
int drawable sprite_b 0x7f020027
|
||||
int drawable sprite_blockline 0x7f020028
|
||||
int drawable sprite_controler 0x7f020029
|
||||
int drawable sprite_freeversion 0x7f02002a
|
||||
int drawable sprite_gameover 0x7f02002b
|
||||
int drawable sprite_i1 0x7f02002c
|
||||
int drawable sprite_i1r 0x7f02002d
|
||||
int drawable sprite_i2 0x7f02002e
|
||||
int drawable sprite_i2r 0x7f02002f
|
||||
int drawable sprite_i3 0x7f020030
|
||||
int drawable sprite_i3r 0x7f020031
|
||||
int drawable sprite_i4 0x7f020032
|
||||
int drawable sprite_i4r 0x7f020033
|
||||
int drawable sprite_l1 0x7f020034
|
||||
int drawable sprite_l2 0x7f020035
|
||||
int drawable sprite_s 0x7f020036
|
||||
int drawable sprite_score 0x7f020037
|
||||
int drawable sprite_t 0x7f020038
|
||||
int drawable sprite_z 0x7f020039
|
||||
int id action_settings 0x7f050005
|
||||
int id hybrid 0x7f050004
|
||||
int id none 0x7f050000
|
||||
int id normal 0x7f050001
|
||||
int id satellite 0x7f050002
|
||||
int id terrain 0x7f050003
|
||||
int integer google_play_services_version 0x7f070000
|
||||
int menu main 0x7f0a0000
|
||||
int raw tetris_a 0x7f030000
|
||||
int string action_settings 0x7f06001b
|
||||
int string app_name 0x7f06001a
|
||||
int string auth_client_needs_enabling_title 0x7f060015
|
||||
int string auth_client_needs_installation_title 0x7f060016
|
||||
int string auth_client_needs_update_title 0x7f060017
|
||||
int string auth_client_play_services_err_notification_msg 0x7f060018
|
||||
int string auth_client_requested_by_msg 0x7f060019
|
||||
int string auth_client_using_bad_version_title 0x7f060014
|
||||
int string common_google_play_services_enable_button 0x7f060006
|
||||
int string common_google_play_services_enable_text 0x7f060005
|
||||
int string common_google_play_services_enable_title 0x7f060004
|
||||
int string common_google_play_services_install_button 0x7f060003
|
||||
int string common_google_play_services_install_text_phone 0x7f060001
|
||||
int string common_google_play_services_install_text_tablet 0x7f060002
|
||||
int string common_google_play_services_install_title 0x7f060000
|
||||
int string common_google_play_services_invalid_account_text 0x7f06000c
|
||||
int string common_google_play_services_invalid_account_title 0x7f06000b
|
||||
int string common_google_play_services_network_error_text 0x7f06000a
|
||||
int string common_google_play_services_network_error_title 0x7f060009
|
||||
int string common_google_play_services_unknown_issue 0x7f06000d
|
||||
int string common_google_play_services_unsupported_date_text 0x7f060010
|
||||
int string common_google_play_services_unsupported_text 0x7f06000f
|
||||
int string common_google_play_services_unsupported_title 0x7f06000e
|
||||
int string common_google_play_services_update_button 0x7f060011
|
||||
int string common_google_play_services_update_text 0x7f060008
|
||||
int string common_google_play_services_update_title 0x7f060007
|
||||
int string common_signin_button_text 0x7f060012
|
||||
int string common_signin_button_text_long 0x7f060013
|
||||
int string hello_world 0x7f06001c
|
||||
int style AppBaseTheme 0x7f090000
|
||||
int style AppTheme 0x7f090001
|
||||
int[] styleable AdsAttrs { 0x7f010000, 0x7f010001, 0x7f010002 }
|
||||
int styleable AdsAttrs_adSize 0
|
||||
int styleable AdsAttrs_adSizes 1
|
||||
int styleable AdsAttrs_adUnitId 2
|
||||
int[] styleable MapAttrs { 0x7f010003, 0x7f010004, 0x7f010005, 0x7f010006, 0x7f010007, 0x7f010008, 0x7f010009, 0x7f01000a, 0x7f01000b, 0x7f01000c, 0x7f01000d, 0x7f01000e, 0x7f01000f, 0x7f010010 }
|
||||
int styleable MapAttrs_cameraBearing 1
|
||||
int styleable MapAttrs_cameraTargetLat 2
|
||||
int styleable MapAttrs_cameraTargetLng 3
|
||||
int styleable MapAttrs_cameraTilt 4
|
||||
int styleable MapAttrs_cameraZoom 5
|
||||
int styleable MapAttrs_mapType 0
|
||||
int styleable MapAttrs_uiCompass 6
|
||||
int styleable MapAttrs_uiRotateGestures 7
|
||||
int styleable MapAttrs_uiScrollGestures 8
|
||||
int styleable MapAttrs_uiTiltGestures 9
|
||||
int styleable MapAttrs_uiZoomControls 10
|
||||
int styleable MapAttrs_uiZoomGestures 11
|
||||
int styleable MapAttrs_useViewLifecycle 12
|
||||
int styleable MapAttrs_zOrderOnTop 13
|
||||
@@ -1,3 +0,0 @@
|
||||
# cache for current jar dependency. DO NOT EDIT.
|
||||
# format is <lastModified> <length> <SHA-1> <path>
|
||||
# Encoding is UTF-8
|
||||
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 15 KiB |
@@ -107,6 +107,7 @@ public final class R {
|
||||
public static final int common_google_play_services_update_title = 0x7f060007;
|
||||
public static final int common_signin_button_text = 0x7f060012;
|
||||
public static final int common_signin_button_text_long = 0x7f060013;
|
||||
public static final int location_client_powered_by_google = 0x7f06001a;
|
||||
}
|
||||
public static final class styleable {
|
||||
public static final int[] AdsAttrs = { 0x7f010000, 0x7f010001, 0x7f010002 };
|
||||
|
||||
@@ -13,3 +13,4 @@
|
||||
# Project target.
|
||||
target=android-19
|
||||
android.library.reference.1=../../../../Desktop/adt-bundle-windows-x86_64-20131030/adt-bundle-windows-x86_64-20131030/sdk/extras/google/google_play_services/libproject/google-play-services_lib
|
||||
android.library=false
|
||||
|
||||
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 907 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 897 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 904 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 902 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 908 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 898 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 905 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 905 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 979 B |
|
After Width: | Height: | Size: 822 B |
|
Before Width: | Height: | Size: 906 B |
@@ -0,0 +1,166 @@
|
||||
package mangavalk.tetris;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.media.MediaPlayer;
|
||||
|
||||
public class GameMenu extends GameStateInterface
|
||||
{
|
||||
// GameState.
|
||||
protected int GameState = GS_STOPPED;
|
||||
|
||||
public GameMenu(Activity activity)
|
||||
{
|
||||
super(activity);
|
||||
}
|
||||
|
||||
// Methods.
|
||||
@Override
|
||||
public void DrawFrame(Canvas canvas)
|
||||
{
|
||||
switch(GameState)
|
||||
{
|
||||
case GS_MENU_READY:
|
||||
{
|
||||
ShowMenu(canvas);
|
||||
break;
|
||||
}
|
||||
case GS_PAUSED:
|
||||
{
|
||||
ShowPauseMenu(canvas);
|
||||
break;
|
||||
}
|
||||
case GS_GAMEOVER:
|
||||
{
|
||||
ShowGameOverMenu(canvas);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SendMove(float x, float y, boolean pointerUp)
|
||||
{
|
||||
switch(GameState)
|
||||
{
|
||||
case GS_MENU_READY:
|
||||
{
|
||||
if (!pointerUp)
|
||||
{
|
||||
SetGameState(GS_MENU_START, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GS_PAUSED:
|
||||
{
|
||||
if (!pointerUp)
|
||||
{
|
||||
SetGameState(GS_RESUME, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GS_GAMEOVER:
|
||||
{
|
||||
SetGameState(GS_MENU_READY, false);
|
||||
canvasView.postInvalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetGameState(int gameState, boolean isPostBack)
|
||||
{
|
||||
GameState = gameState;
|
||||
|
||||
switch(GameState)
|
||||
{
|
||||
/*case GS_LOAD:
|
||||
{
|
||||
Load();
|
||||
break;
|
||||
}*/
|
||||
/*case GS_READY:
|
||||
{
|
||||
canvasView.postInvalidate();
|
||||
break;
|
||||
}*/
|
||||
case GS_PAUSED:
|
||||
{
|
||||
canvasView.postInvalidate();
|
||||
break;
|
||||
}
|
||||
case GS_GAMEOVER:
|
||||
{
|
||||
canvasView.postInvalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isPostBack)
|
||||
canvasView.OnGameStateChanged(GameState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
// Set
|
||||
@Override
|
||||
public int GetGameState()
|
||||
{
|
||||
return GameState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPayedVersion(boolean payedVersion) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
// Internal.
|
||||
|
||||
// Audio.
|
||||
MediaPlayer mp;
|
||||
|
||||
// TODO game state
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
// Load Bitmap's.
|
||||
//LoadSprites();
|
||||
|
||||
//LoadFont();
|
||||
|
||||
// Initlialize.
|
||||
|
||||
// Audio
|
||||
mp = MediaPlayer.create(activity, R.raw.tetris_a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Start()
|
||||
{
|
||||
GameState = GS_MENU_READY;
|
||||
canvasView.postInvalidate();
|
||||
}
|
||||
|
||||
// Draw functions.
|
||||
private void ShowMenu(Canvas canvas)
|
||||
{
|
||||
Rect(canvas, 0f, 160f, 0f, 90f, Color.BLUE);
|
||||
}
|
||||
|
||||
private void ShowPauseMenu(Canvas canvas)
|
||||
{
|
||||
Rect(canvas, 0f, 160f, 0f, 90f, Color.RED);
|
||||
}
|
||||
|
||||
private void ShowGameOverMenu(Canvas canvas)
|
||||
{
|
||||
Rect(canvas, 0f, 160f, 0f, 90f, Color.parseColor("lime"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package mangavalk.tetris;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Display;
|
||||
|
||||
public abstract class GameStateInterface
|
||||
{
|
||||
// GameState Parameters
|
||||
final static int GS_STOPPED = 0;
|
||||
final static int GS_LOADING = 1;
|
||||
final static int GS_PLAYING = 2;
|
||||
final static int GS_GAMEOVER = 3;
|
||||
final static int GS_PAUSED = 4;
|
||||
final static int GS_START = 5;
|
||||
final static int GS_LOAD = 6;
|
||||
final static int GS_READY = 7;
|
||||
final static int GS_RESUME = 8;
|
||||
final static int GS_MENU_START = 9;
|
||||
final static int GS_MENU_READY = 10;
|
||||
|
||||
// Variabelen.
|
||||
protected CanvasView canvasView;
|
||||
protected Activity activity = null;
|
||||
|
||||
// Constructer.
|
||||
public GameStateInterface(Activity _activity)
|
||||
{
|
||||
activity = _activity;
|
||||
|
||||
// Set Display Info.
|
||||
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||
DisplayMetrics outMetrics = new DisplayMetrics ();
|
||||
display.getMetrics(outMetrics);
|
||||
|
||||
r = activity.getResources();
|
||||
|
||||
float density = r.getDisplayMetrics().density;
|
||||
|
||||
dpHeight = outMetrics.heightPixels / density;
|
||||
dpWidth = outMetrics.widthPixels / density;
|
||||
|
||||
Height = outMetrics.heightPixels;
|
||||
Width = outMetrics.widthPixels;
|
||||
}
|
||||
|
||||
// Methods.
|
||||
public abstract void DrawFrame(Canvas canvas);
|
||||
|
||||
public abstract void SendMove(float x,float y, boolean pointerUp);
|
||||
|
||||
public abstract void SetGameState(int gameState, boolean isPostBack);
|
||||
|
||||
// New Game State Methods.
|
||||
public abstract void Load();
|
||||
public abstract void Start();
|
||||
|
||||
public abstract void onPause();
|
||||
|
||||
// SetParameters.
|
||||
public void SetCanvas(CanvasView _CanvasView)
|
||||
{
|
||||
canvasView = _CanvasView;
|
||||
}
|
||||
|
||||
public void SetActivity(Activity _Activity)
|
||||
{
|
||||
activity = _Activity;
|
||||
}
|
||||
|
||||
public abstract void SetPayedVersion(boolean payedVersion);
|
||||
|
||||
// Get
|
||||
public abstract int GetGameState();
|
||||
|
||||
// other logic
|
||||
|
||||
// Variabelen.
|
||||
Resources r;
|
||||
|
||||
// Display
|
||||
float dpHeight;
|
||||
float dpWidth;
|
||||
|
||||
float Height;
|
||||
float Width;
|
||||
|
||||
protected void Rect(Canvas canvas, float Top, float Bottom, float Left, float Right, int Color)
|
||||
{
|
||||
Paint paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
paint.setColor(Color);
|
||||
paint.setStyle(Style.FILL);
|
||||
|
||||
canvas.drawRect(
|
||||
GetRealPixelSize(DIP_W, dpWidth, Left),
|
||||
GetRealPixelSize(DIP_H, dpHeight, Top),
|
||||
GetRealPixelSize(DIP_W, dpWidth, Right),
|
||||
GetRealPixelSize(DIP_H, dpHeight, Bottom), paint);
|
||||
}
|
||||
|
||||
final static int DIP_H = 0;
|
||||
final static int DIP_W = 1;
|
||||
|
||||
protected float GetRealPixelSize(int wH, float dpWH, double DIP)
|
||||
{
|
||||
if (wH == DIP_H)
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 160 )), r.getDisplayMetrics());
|
||||
else if (wH == DIP_W)
|
||||
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float)(dpWH * ( DIP / 90 )), r.getDisplayMetrics());
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected float map(float x, float in_min, float in_max, float out_min, float out_max)
|
||||
{
|
||||
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,137 +1,138 @@
|
||||
|
||||
package mangavalk.tetris;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdSize;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
CanvasView canvasClass;
|
||||
private AdView adView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
FrameLayout ll;
|
||||
|
||||
ll = new FrameLayout(this);
|
||||
|
||||
// Create the adView.
|
||||
adView = new AdView(this);
|
||||
adView.setAdUnitId("ca-app-pub-2360519718191877/5428392148");
|
||||
adView.setAdSize(AdSize.BANNER);
|
||||
|
||||
// Initiate a generic request.
|
||||
AdRequest adRequest = new AdRequest.Builder()
|
||||
.addTestDevice("D23CD70B20EE4AF169D112010B8DC97E") // Htc One X
|
||||
.addTestDevice("029011F06A23EB6FFF862E44CC792EF2") // Nexus 7 tablet
|
||||
.build();
|
||||
|
||||
canvasClass = new CanvasView(this);
|
||||
|
||||
canvasClass.PayedVersion = true; // Set payment status
|
||||
|
||||
canvasClass.startLevel = 0;
|
||||
|
||||
if (!canvasClass.PayedVersion)
|
||||
{
|
||||
// Load the adView with the ad request.
|
||||
adView.loadAd(adRequest);
|
||||
}
|
||||
|
||||
ll.addView(canvasClass);
|
||||
|
||||
// Add the adView to it.
|
||||
FrameLayout.LayoutParams adsParams =new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.TOP|android.view.Gravity.CENTER_HORIZONTAL);
|
||||
ll.addView(adView, adsParams);
|
||||
|
||||
setContentView(ll);
|
||||
|
||||
mActivePointers = new SparseArray<PointF>();
|
||||
|
||||
canvasClass.SetActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
canvasClass.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
canvasClass.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
super.onBackPressed();
|
||||
canvasClass.onPause();
|
||||
}
|
||||
|
||||
private SparseArray<PointF> mActivePointers;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
// MotionEvent reports input details from the touch screen
|
||||
// and other input controls. In this case, you are only
|
||||
// interested in events where the touch position changed.
|
||||
|
||||
// get pointer index from the event object
|
||||
int pointerIndex = e.getActionIndex();
|
||||
|
||||
// get pointer ID
|
||||
int pointerId = e.getPointerId(pointerIndex);
|
||||
|
||||
// get masked (not specific to a pointer) action
|
||||
int maskedAction = e.getActionMasked();
|
||||
|
||||
switch (maskedAction) {
|
||||
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
||||
// We have a new pointer. Lets add it to the list of pointers
|
||||
|
||||
PointF f = new PointF();
|
||||
f.x = e.getX(pointerIndex);
|
||||
f.y = e.getY(pointerIndex);
|
||||
canvasClass.sendMove(f.x, f.y, false);
|
||||
mActivePointers.put(pointerId, f);
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_MOVE: { // a pointer was moved
|
||||
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_UP:
|
||||
for (int size = e.getPointerCount(), i = 0; i < size; i++) {
|
||||
PointF point = mActivePointers.get(e.getPointerId(i));
|
||||
if (point != null) {
|
||||
point.x = e.getX(i);
|
||||
point.y = e.getY(i);
|
||||
canvasClass.sendMove(point.x, point.y, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL: {
|
||||
// TODO use data
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
package mangavalk.tetris;
|
||||
|
||||
import com.google.android.gms.ads.AdRequest;
|
||||
import com.google.android.gms.ads.AdSize;
|
||||
import com.google.android.gms.ads.AdView;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.PointF;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseArray;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
public class MainActivity extends Activity
|
||||
{
|
||||
CanvasView canvasClass;
|
||||
private AdView adView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
FrameLayout ll;
|
||||
|
||||
ll = new FrameLayout(this);
|
||||
|
||||
// Create the adView.
|
||||
adView = new AdView(this);
|
||||
adView.setAdUnitId("ca-app-pub-2360519718191877/5428392148");
|
||||
adView.setAdSize(AdSize.BANNER);
|
||||
|
||||
// Initiate a generic request.
|
||||
AdRequest adRequest = new AdRequest.Builder() // Add S5
|
||||
//.addTestDevice("D23CD70B20EE4AF169D112010B8DC97E") // Htc One X
|
||||
.addTestDevice("029011F06A23EB6FFF862E44CC792EF2") // Nexus 7 tablet
|
||||
.addTestDevice("2CA96A8B6B805B3323F65A934FB31DC7") // Samsung Galaxy S5
|
||||
.build();
|
||||
|
||||
canvasClass = new CanvasView(this);
|
||||
|
||||
canvasClass.PayedVersion = true; // Set payment status
|
||||
|
||||
canvasClass.startLevel = 0;
|
||||
|
||||
//if (!canvasClass.PayedVersion)
|
||||
//{
|
||||
// Load the adView with the ad request.
|
||||
adView.loadAd(adRequest);
|
||||
//}
|
||||
|
||||
ll.addView(canvasClass);
|
||||
|
||||
// Add the adView to it.
|
||||
FrameLayout.LayoutParams adsParams =new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT, android.view.Gravity.TOP|android.view.Gravity.CENTER_HORIZONTAL);
|
||||
ll.addView(adView, adsParams);
|
||||
|
||||
setContentView(ll);
|
||||
|
||||
mActivePointers = new SparseArray<PointF>();
|
||||
|
||||
canvasClass.SetActivity(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
canvasClass.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
//canvasClass.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed()
|
||||
{
|
||||
super.onBackPressed();
|
||||
canvasClass.onPause();
|
||||
}
|
||||
|
||||
private SparseArray<PointF> mActivePointers;
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent e) {
|
||||
// MotionEvent reports input details from the touch screen
|
||||
// and other input controls. In this case, you are only
|
||||
// interested in events where the touch position changed.
|
||||
|
||||
// get pointer index from the event object
|
||||
int pointerIndex = e.getActionIndex();
|
||||
|
||||
// get pointer ID
|
||||
int pointerId = e.getPointerId(pointerIndex);
|
||||
|
||||
// get masked (not specific to a pointer) action
|
||||
int maskedAction = e.getActionMasked();
|
||||
|
||||
switch (maskedAction) {
|
||||
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_POINTER_DOWN: {
|
||||
// We have a new pointer. Lets add it to the list of pointers
|
||||
|
||||
PointF f = new PointF();
|
||||
f.x = e.getX(pointerIndex);
|
||||
f.y = e.getY(pointerIndex);
|
||||
canvasClass.sendMove(f.x, f.y, false);
|
||||
mActivePointers.put(pointerId, f);
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_MOVE: { // a pointer was moved
|
||||
|
||||
break;
|
||||
}
|
||||
case MotionEvent.ACTION_UP:
|
||||
for (int size = e.getPointerCount(), i = 0; i < size; i++) {
|
||||
PointF point = mActivePointers.get(e.getPointerId(i));
|
||||
if (point != null) {
|
||||
point.x = e.getX(i);
|
||||
point.y = e.getY(i);
|
||||
canvasClass.sendMove(point.x, point.y, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
break;
|
||||
case MotionEvent.ACTION_CANCEL: {
|
||||
// TODO use data
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 822 B |
|
After Width: | Height: | Size: 375 KiB |
|
After Width: | Height: | Size: 830 B |
|
After Width: | Height: | Size: 4.3 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 897 B |
|
After Width: | Height: | Size: 842 B |
|
After Width: | Height: | Size: 843 B |
|
After Width: | Height: | Size: 837 B |
|
After Width: | Height: | Size: 845 B |
|
After Width: | Height: | Size: 839 B |
|
After Width: | Height: | Size: 846 B |
|
After Width: | Height: | Size: 843 B |
|
After Width: | Height: | Size: 843 B |
|
After Width: | Height: | Size: 839 B |
|
After Width: | Height: | Size: 837 B |