Last active
August 29, 2015 14:06
-
-
Save takashi1975/3a67ff4bb192da14c69e to your computer and use it in GitHub Desktop.
Cocos2d-x v3.x Android 記述しておきたい コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppActivity extends Cocos2dxActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
// TODO Auto-generated method stub | |
super.onCreate(savedInstanceState); | |
//ボリュームの調整 | |
setVolumeControlStream(AudioManager.STREAM_MUSIC); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# std::stoll などをコンパイルしようとしてエラーになる時 | |
# APP_STL := gnustl_static | |
# ↓ | |
APP_STL := c++_static | |
NDK_TOOLCHAIN_VERSION=clang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# *** add method *** | |
def copy_resources_file(src_path, dst_dir, dst_filename): | |
if not os.path.exists(dst_dir): | |
os.mkdir(dst_dir) | |
dst_path = os.path.join(dst_dir, dst_filename) | |
result = True | |
if os.path.isfile(src_path): | |
shutil.copy(src_path , dst_path) | |
else: | |
result = False | |
return result | |
# *** add method *** | |
def copy_resources_icon(app_android_root): | |
# remove app_android_root/assets if it exists | |
assets_dir = os.path.join(app_android_root, "assets") | |
#if os.path.isdir(assets_dir): | |
# shutil.rmtree(assets_dir) | |
#print "Copying assets from ../proj.ios_mac/ios/Resources" | |
# copy resources | |
#os.mkdir(assets_dir) | |
#resources_dir = os.path.join(app_android_root, "../Resources") | |
# We prefer take assets from the iOS project | |
#resources_dir_ios = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources") | |
#resources_dir_icon = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources/Images.xcassets/AppIcon.appiconset") | |
#resources_dir_splash = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources/Images.xcassets/LaunchImage.launchimage") | |
resources_dir_ios = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources") | |
resources_dir_icon = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources") | |
resources_dir_splash = os.path.join(app_android_root, "../proj.ios_mac/ios/Resources") | |
#if os.path.isdir(resources_dir_ios): | |
# copy_files(resources_dir_ios, assets_dir) | |
#else: | |
# print "ERROR: ios resouces dir not found" | |
print "Copy icons to it respective dir" | |
# move icons from assets to it respective dir | |
res_dir = os.path.join(app_android_root, "res") | |
# Icon Size : 144 x 144 | |
src_path = os.path.join(resources_dir_icon, "Icon-144.png") | |
dst_dir = os.path.join(res_dir, "drawable-xxhdpi") | |
if copy_resources_file(src_path, dst_dir, "icon.png"): | |
print "COPY: Icon 144 x 144" | |
else: | |
print "ERROR: Icon 144 x 144 not found" | |
print "ERROR: " + src_path | |
# Icon Size : 96 x 96 ... near Icon-29@3x(87 x 87) | |
src_path = os.path.join(resources_dir_icon, "Icon-96.png") | |
dst_dir = os.path.join(res_dir, "drawable-xhdpi"); | |
if copy_resources_file(src_path, dst_dir, "icon.png"): | |
print "COPY: Icon 96 x 96" | |
else: | |
print "ERROR: Icon 96 x 96 not found" | |
print "ERROR: " + src_path | |
# Icon Size : 72 x 72 | |
src_path = os.path.join(resources_dir_icon, "Icon-72.png") | |
dst_dir = os.path.join(res_dir, "drawable-hdpi") | |
if copy_resources_file(src_path, dst_dir, "icon.png"): | |
print "COPY: Icon 72 x 72" | |
else: | |
print "ERROR: Icon 72 x 72 not found" | |
print "ERROR: " + src_path | |
# Icon Size : 48 x 48 ... near Icon-40(40 x 40) | |
src_path = os.path.join(resources_dir_icon, "Icon-40.png") | |
dst_dir = os.path.join(res_dir, "drawable-mdpi") | |
if copy_resources_file(src_path, dst_dir, "icon.png"): | |
print "COPY: Icon 48 x 48" | |
else: | |
print "ERROR: Icon 48 x 48 not found" | |
print "ERROR: " + src_path | |
# Icon Size : 36 x 36 ... near Icon-29(29 x 29) | |
src_path = os.path.join(resources_dir_icon, "Icon-29.png") | |
dst_dir = os.path.join(res_dir, "drawable-ldpi") | |
if copy_resources_file(src_path, dst_dir, "icon.png"): | |
print "COPY: Icon 36 x 36" | |
else: | |
print "ERROR: Icon 36 x 36 not found" | |
print "ERROR: " + src_path | |
# Splash (640 x 960) | |
src_path = os.path.join(resources_dir_splash, "[email protected]") | |
dst_dir = os.path.join(res_dir, "drawable") | |
if copy_resources_file(src_path, dst_dir, "splash.png"): | |
print "COPY: Splash" | |
else: | |
print "ERROR: Splash not found" | |
print "ERROR: " + src_path | |
def build(build_mode): | |
current_dir = os.path.dirname(os.path.realpath(__file__)) | |
cocos_root = os.path.join(current_dir, "../cocos2d") | |
app_android_root = os.path.join(current_dir, "../") | |
# *** add *** | |
copy_resources_icon(current_dir) | |
# ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-------------------------------------------------------- | |
#コンパイル対象 (cocos new で作成した状態) | |
LOCAL_SRC_FILES := hellocpp/main.cpp \ | |
../../Classes/AppDelegate.cpp \ | |
../../Classes/HelloWorldScene.cpp | |
# ↓ | |
# ↓ | |
# ↓ | |
#-------------------------------------------------------- | |
#コンパイル対象 (Classesフォルダ以下の全てのcppファイルをコンパイル対象) | |
CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp) | |
LOCAL_SRC_FILES := hellocpp/main.cpp | |
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cocos2d-x ver.3.6 でも有効です (2015/08/05現在)