Skip to content

Commit

Permalink
Ready for release v1.0!
Browse files Browse the repository at this point in the history
  • Loading branch information
CharmySoft committed Apr 6, 2015
1 parent e730148 commit 719647d
Show file tree
Hide file tree
Showing 74 changed files with 2,680 additions and 977 deletions.
5 changes: 4 additions & 1 deletion Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ AppDelegate::~AppDelegate() {}

bool AppDelegate::applicationDidFinishLaunching() {
srand(time(NULL));
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
FileUtils::getInstance()->setDefaultResourceRootPath("res/");
#endif
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
//glview = GLViewImpl::createWithRect("Ching Chong Ping Pong", Rect(0, 0, 320, 640), 1);
glview = GLViewImpl::createWithRect("Ching Chong Ping Pong", Rect(0, 0, 800, 600), 1);
glview = GLViewImpl::createWithRect("Ching Chong Ping Pong", Rect(0, 0, 2048*0.45, 1536*0.45), 1);
//glview = GLViewImpl::createWithRect("Ching Chong Ping Pong", Rect(0, 0, DESIGNED_WIDTH, DESIGNED_HEIGHT), 1);
director->setOpenGLView(glview);
//glview->setDesignResolutionSize(DESIGNED_WIDTH, DESIGNED_HEIGHT, ResolutionPolicy::NO_BORDER);
Expand Down
6 changes: 3 additions & 3 deletions Classes/Scene/AboutScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ bool S_About::init()

#define OFFSET_Y__ (320)

auto iconCharmy = Sprite::create("g_charmysoft_logo.png");
iconCharmy->setScale(0.5f);
auto iconCharmy = Sprite::create("g_charmy_av.png");
iconCharmy->setScale(0.6f);
iconCharmy->setAnchorPoint(Vec2(0, 0.5));
iconCharmy->setPosition(E::originX + 24, E::originY + OFFSET_Y__);
this->addChild(iconCharmy, 0);

auto lbCharmy = Label::createWithTTF(S("CharmySoft", "尘泯网络"), FONT_BOLD, 28,
Size(320, 64), TextHAlignment::CENTER, TextVAlignment::CENTER);
lbCharmy->setPosition(E::visibleWidth/2 + 80, E::originY + OFFSET_Y__ + 40);
lbCharmy->setPosition(E::visibleWidth/2 + 80, E::originY + OFFSET_Y__ + 48);
lbCharmy->setAnchorPoint(Vec2(0.5, 0.5));
lbCharmy->setColor(C3B(E::P.C900));
this->addChild(lbCharmy, 0);
Expand Down
15 changes: 8 additions & 7 deletions Classes/Scene/BaseScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void BaseScene::onKeyReleased(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::

bool BaseScene::onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event)
{
utils::captureScreen(nullptr, "D:/a.png");
/*
#ifndef NDEBUG
Vec2 p = touch->getLocation() / E::scale;
Expand Down Expand Up @@ -232,7 +233,7 @@ void BaseScene::putEmitter(Vec2 pos){
void BaseScene::putEmitter2(Vec2 pos){
m_emitterCreated ++;

auto _emitter = ParticleSystemQuad::createWithTotalParticles(100);
auto _emitter = ParticleSystemQuad::createWithTotalParticles(60);
//_emitter->retain();
_emitter->setTag(m_emitterCreated);

Expand Down Expand Up @@ -275,13 +276,13 @@ void BaseScene::putEmitter2(Vec2 pos){
_emitter->setEndSpinVar(360);

// color of particles
_emitter->setStartColor(C4F_(E::P.C700, 0.7f));
_emitter->setStartColor(C4F_(E::P.C700, 0.5f));
_emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));
_emitter->setEndColor(C4F_(E::P.C700, 0.15f));
_emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.15f));

// size, in pixels
_emitter->setStartSize(28.0f);
_emitter->setStartSize(32.0f);
_emitter->setStartSizeVar(4.0f);
_emitter->setEndSize(ParticleSystem::START_SIZE_EQUAL_TO_END_SIZE);

Expand All @@ -300,7 +301,7 @@ void BaseScene::putEmitter2(Vec2 pos){
void BaseScene::putEmitter3(Vec2 pos){
m_emitterCreated ++;

auto _emitter = ParticleSystemQuad::createWithTotalParticles(40);
auto _emitter = ParticleSystemQuad::createWithTotalParticles(20);
//_emitter->retain();
_emitter->setTag(m_emitterCreated);

Expand Down Expand Up @@ -337,10 +338,10 @@ void BaseScene::putEmitter3(Vec2 pos){
_emitter->setLifeVar(0.8f);

// color of particles
_emitter->setStartColor(C4F_(E::P.C500, 0.8f));
_emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));
_emitter->setStartColor(C4F_(E::P.C500, 0.4f));
_emitter->setStartColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.3f));
_emitter->setEndColor(C4F_(E::P.C300, 0.3f));
_emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.15f));
_emitter->setEndColorVar(Color4F(0.1f, 0.1f, 0.1f, 0.2f));

// size, in pixels
_emitter->setStartSize(32.0f);
Expand Down
3 changes: 2 additions & 1 deletion Classes/Scene/LevelPickerScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool S_LevelPicker::init()
CPalette[i]->setScale(0.3f);
CPalette[i]->setAnchorPoint(Vec2(0, 0));
CPalette[i]->setTag(TAG_COLOR_MENU+i);
auto lbLevel = Label::createWithTTF(stdp::to_string(i+1), FONT_BOLD, 128,
auto lbLevel = Label::createWithTTF(i+1 > E::settings.unlockedLevel? "?": stdp::to_string(i+1), FONT_BOLD, 128,
CPalette[i]->getContentSize(), TextHAlignment::CENTER, TextVAlignment::CENTER);
lbLevel->setPosition(CPalette[i]->getContentSize()/2);
//lbLevel->setAnchorPoint(Vec2(0.5, 0.5));
Expand Down Expand Up @@ -273,6 +273,7 @@ void S_LevelPicker::menuCallback(Ref* pSender)

void S_LevelPicker::_ok(){
E::settings.currentLevel = m_tempLevel;
UserDefault::getInstance()->setIntegerForKey(UD_CURRENT_LEVEL, E::settings.currentLevel);
m_bClose = 1;
runAnimations(true);
}
Expand Down
28 changes: 21 additions & 7 deletions Classes/Scene/MainGameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool S_MainGame::init()
// super init
if (!BaseScene::init(E::P.C100)){return false;}
#ifndef NDEBUG
//E::settings.currentLevel = 19;
//E::settings.currentLevel = 21;
E::settings.unlockedLevel = 22;
#endif

Expand Down Expand Up @@ -263,13 +263,21 @@ void S_MainGame::onKeyEvent(EventKeyboard::KeyCode keyCode, cocos2d::Event *even
}

void S_MainGame::backHomeDialog(){
auto leaveDialog = BallDialog::create(S("If you go back to home page, your current game will be lost, are you sure?", "返回主菜单后当前游戏数据将丢失,您确定要返回主菜单吗?"), CC_CALLBACK_0(S_MainGame::leaveGame, this));
this->addChild(leaveDialog, 1000);
static BallDialog* leaveDialog = nullptr;
if(leaveDialog == nullptr || leaveDialog->isValid() == false){
leaveDialog = BallDialog::create(S("If you go back to home page, your current game will be lost, are you sure?", "返回主菜单后当前游戏数据将丢失,您确定要返回主菜单吗?"), CC_CALLBACK_0(S_MainGame::leaveGame, this));
leaveDialog->setReferencer(&leaveDialog);
this->addChild(leaveDialog, 1000);
}
}

void S_MainGame::pickLevelDialog(){
auto leaveDialog = BallDialog::create(S("If you pick a new level, your current game will be lost, are you sure?", "选择新的关卡后当前游戏数据将丢失,您确定要选择关卡吗?"), CC_CALLBACK_0(S_MainGame::pickLevel, this));
this->addChild(leaveDialog, 1000);
static BallDialog* pickLevelDialog = nullptr;
if(pickLevelDialog == nullptr || pickLevelDialog->isValid() == false){
pickLevelDialog = BallDialog::create(S("If you pick a new level, your current game will be lost, are you sure?", "选择新的关卡后当前游戏数据将丢失,您确定要选择关卡吗?"), CC_CALLBACK_0(S_MainGame::pickLevel, this));
pickLevelDialog->setReferencer(&pickLevelDialog);
this->addChild(pickLevelDialog, 1000);
}
}

void S_MainGame::pickLevel(){
Expand Down Expand Up @@ -339,6 +347,8 @@ void S_MainGame::restartGame(){
addChild(m_game, 2);
m_game->runAction(Sequence::create(DelayTime::create(0.6f), FadeIn::create(0.3f), nullptr));
}
m_smartstring->stopGoing();



}
Expand Down Expand Up @@ -422,8 +432,12 @@ void S_MainGame::menuCallback(Ref* pSender)

case TAG_RESTART:
{
auto leaveDialog = BallDialog::create(S("Do you want to restart this game?", "是否想要重新开始这一关?"), CC_CALLBACK_0(S_MainGame::restartGame, this));
this->addChild(leaveDialog, 1000);
static BallDialog* restartDialog = nullptr;
if(restartDialog == nullptr || restartDialog->isValid() == false){
restartDialog = BallDialog::create(S("Do you want to restart this game?", "是否想要重新开始这一关?"), CC_CALLBACK_0(S_MainGame::restartGame, this));
restartDialog->setReferencer(&restartDialog);
this->addChild(restartDialog, 1000);
}
break;
}
case TAG_HOME:
Expand Down
2 changes: 1 addition & 1 deletion Classes/Scene/SplashScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bool S_Splash::init()
}

auto iconCharmy = Sprite::create("g_charmysoft_logo.png");
iconCharmy->setScale(0.8f);
iconCharmy->setScale(0.75f);
iconCharmy->setAnchorPoint(Vec2(0.5, 0.5));
iconCharmy->setOpacity(0);
iconCharmy->setPosition(E::visibleWidth / 2, E::visibleHeight / 2);
Expand Down
13 changes: 7 additions & 6 deletions Classes/UI/BallDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ USING_NS_CC;
#define TAG_CANCEL 1

BallDialog::BallDialog() {
m_referencer = nullptr;
}

BallDialog::~BallDialog() {
Expand Down Expand Up @@ -152,7 +153,6 @@ void BallDialog::runAnimations(bool bReverse){
E::playEffect("da");
m_callbackOK();
}
this->removeFromParentAndCleanup(true);
break;
}

Expand All @@ -163,17 +163,18 @@ void BallDialog::runAnimations(bool bReverse){
E::playEffect("da");
m_callbackCancel();
}
this->removeFromParentAndCleanup(true);
break;
}
default:
{
this->removeFromParentAndCleanup(true);
break;
}
}


this->removeFromParentAndCleanup(true);
if(m_referencer != nullptr && *m_referencer != nullptr){
*m_referencer = nullptr;
m_referencer = nullptr;
}
});
auto seq = Sequence::create(DelayTime::create(0.4f), callback, nullptr);
this->runAction(seq);
Expand All @@ -185,4 +186,4 @@ void BallDialog::menuCallback(Ref* pSender)
auto pMenuItem = (MenuItem*)pSender;
m_resultTag = pMenuItem->getTag();
runAnimations(true);
}
}
3 changes: 3 additions & 0 deletions Classes/UI/BallDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class BallDialog : public cocos2d::Sprite
~BallDialog();
static BallDialog* create(const std::string = "", const std::function<void(void)>& callbackOK = nullptr, const std::function<void(void)>& callbackCancel = nullptr, const std::string ok = "ui/b_ok.png", const std::string cancel = "ui/b_cancel.png");
void runAnimations(bool);
bool isValid(){return m_listenerId != -1;};
void setReferencer(BallDialog** referencer){m_referencer = referencer;};

private:
void addEvents();
Expand All @@ -25,6 +27,7 @@ class BallDialog : public cocos2d::Sprite
void initOpt(std::string, std::string);
void menuCallback(cocos2d::Ref* pSender);
int m_listenerId;
BallDialog** m_referencer;

};

Expand Down
Binary file added Resources/g_charmy_av.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/g_charmysoft_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions proj.android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>



<supports-screens android:anyDensity="true"
android:smallScreens="true"
Expand All @@ -35,4 +38,5 @@
android:xlargeScreens="true"/>

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Binary file removed proj.android/res/drawable-xxxhdpi/icon.png
Binary file not shown.
Binary file added proj.android/res/drawable/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions proj.android/src/org/cocos2dx/cpp/AppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,106 @@ of this software and associated documentation files (the "Software"), to deal
****************************************************************************/
package org.cocos2dx.cpp;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import org.cocos2dx.lib.Cocos2dxActivity;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;

public class AppActivity extends Cocos2dxActivity {
// Buffer size used.
private final static int BUFFER_SIZE = 1024;
static Activity a;
static File file = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
a = this;
super.onCreate(savedInstanceState);
}
public static void Charmy_Share() {
new Thread(new Runnable() {
public void run() {
if(file == null || !file.exists()){
CopyShareToSdCard();
file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/ccpp.png");
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_SUBJECT, "Ching Chong Ping Pong");
intent.putExtra(Intent.EXTRA_TEXT, "Check out this extradinary game, Ching Chong Ping Pong! It's real fun! http://www.CharmySoft.com");
intent.putExtra(Intent.EXTRA_STREAM,
Uri.fromFile(file));
a.startActivity(Intent.createChooser(intent, "Share Game"));
}
}).start();
}

public static void Charmy_Rate(){
Uri uri = Uri.parse("market://details?id=" + a.getApplicationContext().getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
try {
a.startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
a.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + a.getApplicationContext().getPackageName())));
}
}

private static void CopyShareToSdCard() {
try{
AssetManager assetManager = a.getApplicationContext().getAssets();
InputStream in = assetManager.open("share.png");
OutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/ccpp.png");
copyAssetFiles(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}

}


private static void copyAssetFiles(InputStream in, OutputStream out) {
try {

byte[] buffer = new byte[BUFFER_SIZE];
int read;

while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}

in.close();
in = null;
out.flush();
out.close();
out = null;

} catch (IOException e) {
} catch (NullPointerException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}

}
Loading

0 comments on commit 719647d

Please sign in to comment.