【发布时间】:2010-10-04 09:07:45
【问题描述】:
大家好, 我是游戏开发部分的新手。任何人都可以帮助我如何开发游戏。因为直到今天我都在开发普通的 iphone 应用程序。我可以通过选择基于窗口或视图的应用程序来开发游戏。如果是,那么给我某种示例代码或链接。 在此先感谢
【问题讨论】:
标签: iphone objective-c
大家好, 我是游戏开发部分的新手。任何人都可以帮助我如何开发游戏。因为直到今天我都在开发普通的 iphone 应用程序。我可以通过选择基于窗口或视图的应用程序来开发游戏。如果是,那么给我某种示例代码或链接。 在此先感谢
【问题讨论】:
标签: iphone objective-c
最好用cocos2d这样的游戏引擎。但是您也可以通过选择基于视图的应用程序来制作游戏。请参阅“Apress 开始 iPhone 游戏开发”,它对您有很大帮助。
【讨论】:
说实话,您可能最好使用游戏引擎 (google cocos2d) 或类似引擎。它们带有自己的起始模板,您可以使用它们,而不是使用基于视图或窗口的应用程序。
【讨论】:
你应该在精灵类的帮助下制作对象。你可以在 Apress 书的帮助下制作 Sprite 和 AtlasSprite 类。并在使用前阅读所有关于这些类的信息。
Sprite *obj; (in .h file)
//in .m file
obj = [AtlasSprite fromFile:@"img.png" withRows:1 withColumns:1];
//now set the properties of the obj.
//for moving set
obj.x = 20; obj.y = 25; //by default x,y is 0,0
obj.speed = 120; //120 is just for example
obj.angle = 0; //for left to right movement
obj.angle = 180; //for right to left movement
timer = [NSTimer scheduledWithTimeInterval:1/10 target:self selector:@selector(func) userInfo:nil repeats:YES];
-(void)func {
[obj tic:1/20]; //for moving obj. 1/20 is just for example
}
【讨论】: