oc 翻译到cocos2dx 过程中的知识点
发布时间:2020-12-14 16:28:04 所属栏目:百科 来源:网络整理
导读:首先遇到在oc里面的 (声明下面在写的时候没有立马测试因为没翻译全边翻译边写博客的) clearColor [UIColor clearColor] 在cocos里面没有 查阅下oc资料发现 + ( UIColor *)clearColor; // 0.0 white,0.0 alpha 而cocos2dx const Color4B Color4B::WHITE ( 2
首先遇到在oc里面的 (声明下面在写的时候没有立马测试因为没翻译全边翻译边写博客的)
[UIColor clearColor] 在cocos里面没有 + (UIColor *)clearColor; // 0.0 white,0.0 alpha
而cocos2dx const Color4B Color4B::WHITE (255,255,255);
于是大胆猜测 #define Color4BClearColor Color4B(255,255,0)
在oc里面有背景颜色 backgroundColor
vector<int> ***::getRecentNodesTagOftheNode()
{
vector<int> recentNodesList {-9,-8,-7,-1,1,7,8,9};
if (0 == tag % 8) {
int rightIndexs[] = {2,4,7};
for (int i=0; i<3; ++i) {
recentNodesList[rightIndexs[i]] = -1;
}
}
***
return recentNodesList;
}
比如我在写五子棋的时候活四,活三,,,等算他们的价值的时候不必要使用#define typedef NS_ENUM (NSInteger,GAMESTATE)
{
GAMEREADY = 0,GAMEING,GAMEOVER
};
-> typedef enum
{
GAMEREADY = 0,GAMEOVER
}GAMESTATE;
[view viewWithTag:nTag] -> node->getChildByTag(nTag)
tempNode isKindOfClass:[** class]
typeid( i ) == typeid( int )
node.transform = CGAffineTransformMakeScale(0.9,0.9);
意思好像就是view的缩放 [UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationRepeatCount:MAXFLOAT];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:YES];
node.transform = CGAffineTransformMakeScale(0.9,0.9);
[UIView commitAnimations];
-> chessNode->runAction(ScaleTo::create(0.5,0.9,0.9));
node->chessNode->runAction(RepeatForever::create( ScaleTo::create(0,1) ));//加上重复
runAction(RepeatForever::create( EaseInOut::create(ScaleTo::create(0,1),1) ));//加上EaseInOut
chessNode->runAction(ScaleTo::create(0.5,0.9));//或者这个但是为了匹配上面的两个0.9
哇好像更简洁了当然oc那边也有简洁的 [UIView animateWithDuration:0 animations:^{ node.transform = CGAffineTransformMakeScale(1,1); }];
u_int32_t arc4random(void);
std::rand()
[changeSumList indexOfObject:[changeSumList valueForKeyPath:@"@max.self"]]//意思是最大值所在的位置
我这里就随便弄一段搓代码代替了 int maxOfIndex = 0;
for (int i =1; i<changeSumList.size(); i++) { if (changeSumList[maxOfIndex] < changeSumList[i]) { maxOfIndex = i; }
}
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(ctx,(i == 0 || i==kSize)?5:2.0);
CGContextSetStrokeColorWithColor(ctx,[[UIColor purpleColor] CGColor]);
CGContextMoveToPoint(ctx,10,10+kNodeWidth*i);
CGContextAddLineToPoint(ctx,10+kNodeWidth*kSize,10+kNodeWidth*i);
CGContextStrokePath(ctx);
*****
DrawNode* drawNode = DrawNode::create();
drawNode->....
addChild(drawNode);
后面翻译的时候,忘记在这边写了。。。。以后补上 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |