弹珠台游戏开发全解析
1. 物理模拟与帧率的关系
物理模拟代码的效果是,物理模拟将独立于帧率进行更新。不过,若帧率降得过低,物理模拟会以恒定速度更新。
2. 创建弹珠台
弹珠台由三个单独的图像及其关联形状构成,分别名为 table - top、table - left 和 table - bottom。我们将使用继承自 BodyNode 的 TablePart 类来创建弹珠台。
TablePart 类的头文件如下:
#import "BodyNode.h"
@interface TablePart : BodyNode
{
}
+(id) tablePartInWorld:(b2World*)world position:(CGPoint)pos name:(NSString*)name;
@end
TablePart 类的实现代码如下:
@implementation TablePart
-(id) initWithWorld:(b2World*)world position:(CGPoint)pos name:(NSString*)name
{
if ((self = [super initWithShape:name inWord:world]))
{
// set the body position
body->SetTransform([Helper toMeters:pos], 0.0f);
超级会员免费看
订阅专栏 解锁全文
59

被折叠的 条评论
为什么被折叠?



