【发布时间】:2014-07-18 05:47:59
【问题描述】:
我刚刚开始使用 cocos3d,我正在制作一个基本的纸牌游戏。我已经有了带有纹理的模型,但我不知道如何指定给定对象或节点使用的纹理。我已经使用基本的 cocos3d 模板加载和渲染纹理模型。这是我的设置代码:
//Init
for ( int i = 0; i < 5; ++i )
{
cardNodes[i] = [CC3PODResourceNode nodeFromFile: @"Card.pod"];
[self addChild:cardNodes[i]];
cardNodes[i].location = cc3v ( ( i - 2)*7.5, 0, 0);
cardNodes[i].rotation = cc3v ( 0,-90,180);
}
-(void) startGame
{
srand(0);
//Draw 5 random cards
unsigned int cards[5] = {0};
for ( unsigned int i = 0; i < 5; ++i )
{
unsigned int card = ( rand() % 52 ) + 1;
for ( int other = i-1; other >= 0; --other )
{
if ( cards[other] == card )
{
card = ( rand() % 52 ) + 1;
other = i-1;
}
}
cards[i] = card;
//Set texture of card node[i] somehow here?
}
}
那么如何更改正在使用的纹理,这样我就不必为每张卡创建新的 pod 文件了?
【问题讨论】:
标签: objective-c cocos3d