wow
It’s so cold…
It’s so cold…
hello, world.
Mother Fucker What’s In Charge or Mother Fucker Who’s In Charge.
http://answers.yahoo.com/question/index?qid=20080614034218AAGNqe4
暇のある時に興味のある文章を勝手に翻訳しています。
Best Answer – Chosen by Voters
Engish is the standard form of communication. It’s used worldwide by people who are from different countries but need to communicate with each other.
English is also seen as the business language, as for reasons mentioned above.
We study it also for the reasons we study any language-we need to have a way to articulate the things we need and desire.
English is also used primarily on the internet-which today connects millions of people world wide.
English is used in many different countries also because curing the Colonial and Imperial Age, Britain proved to be “successful” at gaining colonies on different continents around the world.
どうして私たちは英語を学ぶ必要があるのですか?
ベストアンサー – 投票により選ばれました
英語はコミュニケーションの基準となるものです。世界中の異なる国から来た人に使われています、お互いのコミュニケーションのために必要です。
上に書いた理由により、英語はビジネスシーンにおいても同様です。
また、英語はインターネット上でおもに使用される言語です。インターネットは世界中で何億人もの人が接続しています。
英語は異なるたくさんの国で使用されていて、その理由は植民地(帝国)時代にイギリスが世界に広げる事に成功したためです。
実例でみるiPhoneアプリ内課金(In App Purchase) アプリへの組み込み
こちらを参考に実装してみたが、課金が成功した際にStoreKitが自動で表示すると思われる最後のダイアログが表示されない。(以前は表示されていたようだ)
テストユーザーで何度試しても課金には成功しているが、ダイアログが表示されない模様。
これは一体・・どこを調べればいいのだろう・・・
スクリーンショットも自分で”課金成功”ってダイアログ出したらいいのだろうか・・・?
ボールとか、つかむ感じですな。
from http://www.cocos2d-iphone.org/forum/topic/2621
ヘッダにこれ
b2World* world; GLESDebugDraw *m_debugDraw; b2Vec2 m_mouseWorld; b2MouseJoint *m_mouseJoint;
m_mouseJointはinitでNullいれとかないと落ちるかもしれない。
ソースにこれを追加
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
location = [self convertToNodeSpace:location];
m_mouseWorld.Set(ptm(location.x), ptm(location.y));
if (m_mouseJoint != NULL)
{
return;
}
b2AABB aabb;
b2Vec2 d = b2Vec2(0.001f, 0.001f);
aabb.lowerBound = m_mouseWorld - d;
aabb.upperBound = m_mouseWorld + d;
// Query the world for overlapping shapes.
QueryCallback callback(m_mouseWorld);
world->QueryAABB(&callback, aabb);
if (callback.m_fixture)
{
b2BodyDef bodyDef;
b2Body* groundBody = world->CreateBody(&bodyDef);
b2Body* bodyz = callback.m_fixture->GetBody();
bodyz->SetAwake(true);
b2MouseJointDef md;
md.bodyA = groundBody;
md.bodyB = bodyz;
md.target = m_mouseWorld;
md.maxForce = 1000.0f * bodyz->GetMass();
m_mouseJoint = (b2MouseJoint*)world->CreateJoint(&md);
}
[self addNewSpriteWithCoords:location];
}
- (void)ccTouchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
UITouch* myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
location = [self convertToNodeSpace:location];
m_mouseWorld.Set(ptm(location.x), ptm(location.y));
if (m_mouseJoint)
{
m_mouseJoint->SetTarget(m_mouseWorld);
}
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self ccTouchesCancelled:touches withEvent:event];
}
- (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
if (m_mouseJoint)
{
world->DestroyJoint(m_mouseJoint);
m_mouseJoint = NULL;
}
}
あと、QueryCallback.hはこれ。ヘッダだけです(見たらわかるけど)
#import "Box2D.h"
class QueryCallback : public b2QueryCallback
{
public:
QueryCallback(const b2Vec2& point)
{
m_point = point;
m_fixture = NULL;
}
bool ReportFixture(b2Fixture* fixture)
{
b2Body* body = fixture->GetBody();
if (body->GetType() == b2_dynamicBody)
{
bool inside = fixture->TestPoint(m_point);
if (inside)
{
m_fixture = fixture;
// We are done, terminate the query.
return false;
}
}
// Continue the query.
return true;
}
b2Vec2 m_point;
b2Fixture* m_fixture;
};
Cocos2d+Box2dでニュートンの万有引力の法則を表現する。
基本的にBox2dではサポートしてないみたいなので、サンプルを探す。
ー>
いちいちオブジェクトごとにApplyForceするだけで引力っぽい。
なんだろうこの煮え切らない感じ。
http://stackoverflow.com/questions/6758060/simulate-newtons-law-of-universal-gravitation-using-box2d
also
http://www.vellios.com/2010/06/06/box2d-and-radial-gravity-code/
-(void) tick: (ccTime) dt
{
int32 velocityIterations = 8;
int32 positionIterations = 1;
world->Step(dt, velocityIterations, positionIterations);
for (b2Body* b = world->GetBodyList(); b; b = b->GetNext())
{
if (b->GetUserData() != NULL) {
//Synchronize the AtlasSprites position and rotation with the corresponding body
CCSprite *myActor = (CCSprite*)b->GetUserData();
myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO);
myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
}
b2Vec2 pi = b->GetWorldCenter();
float mi = b->GetMass();
for (b2Body* bk = b->GetNext(); bk; bk = bk->GetNext()){
b2Vec2 pk = bk->GetWorldCenter();
float mk = bk->GetMass();
b2Vec2 delta = pk - pi;
float r = delta.Length();
float force = 1.0f * mi * mk / (r*r);
delta.Normalize();
b->ApplyForce( force * delta, pi );
bk->ApplyForce( -force * delta, pk );
}
}
}
from
http://stackoverflow.com/questions/6697247/how-to-create-plist-files-programmatically-in-iphone
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"plist.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath: path])
{
path = [documentsDirectory stringByAppendingPathComponent: [NSString stringWithFormat: @"plist.plist"] ];
}
NSMutableDictionary *dict;
if ([fileManager fileExistsAtPath: path])
{
dict = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
}
else
{
// If the file doesn’t exist, create an empty dictionary
dict = [[NSMutableDictionary alloc] init];
}
//To insert the data into the plist
int value = 5;
[dict setObject:[NSNumber numberWithInt:value] forKey:@"value"];
[dict writeToFile: path atomically:YES];
[dict release];
//To reterive the data from the plist
NSMutableDictionary *savedStock = [[NSMutableDictionary alloc] initWithContentsOfFile: path];
int value1;
value1 = [[savedStock objectForKey:@"value"] intValue];
NSLog(@"%i",value1);
[savedStock release];
This is very easy.
1.download cocos2d.
2.install.
3.done.
1. Download cocos2d [cocos2d-iphone-1.0.1.tar.gz] from http://www.cocos2d-iphone.org/download
and extract that tar.
2. open shell and execute “install-templates.sh” script on your mac.
however, this script need a root permit.
example sudo ./install-templates.sh -f