Skip to content

Instantly share code, notes, and snippets.

View ryohey's full-sized avatar
👶

ryohey ryohey

👶
View GitHub Profile
@ryohey
ryohey / fadeout
Created September 16, 2013 13:20
#!/bin/bash
for in_file in $(ls -1 *.wav)
do
out_file="fade/${in_file}.wav"
echo "Processing: \"$in_file\". Saving as \"$out_file\" ..."
sox "$in_file" "$out_file" fade t 0 0 2
done
@ryohey
ryohey / gist:8591621
Last active April 20, 2016 05:48
create MenuItemLabel in cocos2d-x v3.0beta0
auto item1 = MenuItemLabel::create(LabelTTF::create("[$200]", "Courier New.ttf", 51),
[](Object *obj) {
CCLOG("item1 touched");
});
auto item2 = MenuItemLabel::create(LabelTTF::create("[$500]", "Courier New.ttf", 51),
[](Object *obj) {
CCLOG("item2 touched");
}
});
@ryohey
ryohey / gist:8591635
Created January 24, 2014 03:34
create Particle from plist in cocos2d-x v3.0beta0
auto explosion = ParticleSystemQuad::create("explosion.plist");
explosion->setAnchorPoint(Point::ANCHOR_MIDDLE);
explosion->setPosition(Point(200, 200));
explosion->setAutoRemoveOnFinish(true);
addChild(explosion);
@ryohey
ryohey / gist:8591683
Created January 24, 2014 03:41
create Touch Event Listener and set up callback methods in cocos2d-x v3.0beta0
// in a layer initialize method such as the onEnter
auto listener = cocos2d::EventListenerTouchOneByOne::create();
listener->onTouchBegan = [](Touch *, Event *) {
// do something
return true;
};
listener->onTouchMoved = [](Touch* touch, Event* event) {
@ryohey
ryohey / gist:8591767
Created January 24, 2014 03:49
animate a Sprite from the sprite image in cocos2d-x v3.0beta0
Size size = Size(128, 128);
auto frames = new Vector<SpriteFrame *>();
for (int x = 0; x <= 10; ++x) {
auto rect = Rect(x * size.width, 0, size.width, size.height);
auto frame = SpriteFrame::create("walkingZombieSprite.png", rect);
frames->pushBack(frame);
}
auto animation = Animation::createWithSpriteFrames(*frames);
@ryohey
ryohey / gist:8591805
Created January 24, 2014 03:54
Calling a Callback after the Action using Sequence Example in cocos2d-x v3.0beta0
auto jump = JumpBy::create(0.5, Point(0, 0), 100, 1);
auto callback = CallFunc::create([](){
CCLog("Jumped!");
});
auto seq = Sequence::create(jump, callback, NULL);
sprite->runAction(seq);
@ryohey
ryohey / MyMenuItemLabel.cpp
Last active January 4, 2016 07:59
Add Touch Up Callback in MenuItem for Make own GamePad in cocos2d-x v3.0beta0
#include "MyMenuItemLabel.h"
MyMenuItemLabel *MyMenuItemLabel::create(Node*label, const ccMenuCallback& selected, const ccMenuCallback& unselected) {
MyMenuItemLabel *ret = new MyMenuItemLabel();
ret->initWithLabel(label, selected, unselected);
ret->autorelease();
return ret;
}
@ryohey
ryohey / gist:8592094
Created January 24, 2014 04:28
Practical Collision Detection in cocos2d-x v3.0beta0
/**
* The problem is the damage effect that changes boundingBox while detecting collision.
* To detect collision correctly, We need to make lists of collided sprites.
*
* Character Class inherited Node and implemted onCollision method.
*
* class Character: public Node {
* public:
* onCollision(Vector<Character *> *characters);
* }
@ryohey
ryohey / gist:8702280
Created January 30, 2014 04:00
touch referenced directories Run Script to refresh cocos2d-x js and image resources
touch -cm ${SRCROOT}/../Resources/src
touch -cm ${SRCROOT}/../Resources/res
@ryohey
ryohey / ___FILEBASENAME___.cpp
Last active August 29, 2015 13:56
C++ Class.xctemplate
//
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
//
#include "___FILEBASENAME___.h"