Skip to content

Instantly share code, notes, and snippets.

View tadamatu's full-sized avatar

Tadashi Matsuda tadamatu

  • BASE.inc
  • Kanagawa, Japan
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tadamatu
tadamatu / Info.plist
Last active October 21, 2015 16:30
iOS9にするとアプリ内のサイト表示ができなくなったときの解決法(HTTP通信ができない) ref: http://qiita.com/tadamatu/items/02b706bb21f9300276d8
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>tadamatu0001.web.fc2.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
@tadamatu
tadamatu / GameScene.cpp
Last active October 21, 2015 16:30
【cocos2d-x】物理エンジンの重力を変更したらモンストも作れるぞ! ref: http://qiita.com/tadamatu/items/df7e9ad060462936fcde
// 固定された物体(壁などに利用)
auto map = this->addNewBoxAtPosition(this, Point(0, 100), false, "map.png");
// 物理計算されてダイナミックに動く物体(プレイヤーなどに利用)
auto player = this->addNewBoxAtPosition(this, Point(100, 100), true, "player.png");
@tadamatu
tadamatu / AndroidManifest.xml
Last active October 21, 2015 16:31
cocos2d-xの画面の向き(縦横)は設定だけでは済まないのでまとめておく ref: http://qiita.com/tadamatu/items/98a9539ab3dd951489f5
<activity android:name="org.cocos2dx.cpp.AppActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" //★この部分★
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:configChanges="orientation">
@tadamatu
tadamatu / ScreenShot.cpp
Last active March 9, 2016 09:58
cocos2d-xでスクリーンショットをとってシェアする機能を実装する ref: http://qiita.com/tadamatu/items/ec26316822b73d66df30
// スクリーンショットを取得し、ツイートする
void screenShot() {
// スクリーンショットのテクスチャを取得する
Size size = Director::getInstance()->getWinSize();
RenderTexture* texture = RenderTexture::create((int)size.width, (int)size.height);
texture->setPosition(Point(size.width/2, size.height/2));
texture->begin();
Director::getInstance()->getRunningScene()->visit();
texture->end();
@tadamatu
tadamatu / LocalizedString.cpp
Last active December 10, 2018 10:57
ローカライズ文字の取得関数
//[cocos2d-x]
//ローカライズ文字の取得関数
//searchKey 対象キー
//comment コメント(覚書などに利用)
//Return ローカライズ文字列
std::string LocalizedString(const char* searchKey, const char* comment){
std::string ret = comment;
static map<std::string, std::string> localizable;
if(localizable.empty()){
@tadamatu
tadamatu / split.cpp
Last active August 29, 2015 14:25
文字列をデリミタで分解しリスト化する関数
//[cocos2d-x]
//文字列をデリミタで分解しリスト化する関数
//str 対象文字列
//delim デリミタ
//Return 分解後リスト
std::list<std::string> split(std::string str, std::string delim) {
std::list<std::string> result;
long cutAt;
@tadamatu
tadamatu / trim.cpp
Created July 25, 2015 01:49
トリミング関数
//[cocos2d-x]
//トリミング関数
//str 対象文字列
//[trimCharacterList] トリミングしたい文字
//Return トリミング後の文字列
std::string trim(const std::string& str, const char* trimCharacterList = "; \t\v\r\n\"\'") {
std::string result;
std::string::size_type left = str.find_first_not_of(trimCharacterList);
if (left != std::string::npos) {
@tadamatu
tadamatu / stringReplace.cpp
Created July 25, 2015 01:46
文字列の置換
//[cocos2d-x]
//文字列の置換
//target 対象文字列
//from 検索する文字列(置換される文字列)
//to 置換する文字列
//Return 置換後文字列
std::string stringReplace(const std::string target, const std::string from, const std::string to) {
std::string result = target;
std::string::size_type pos = 0;
while(pos = result.find(from, pos), pos != std::string::npos) {