回顾一下上一次的教程orz,也许有许多地方没有说清楚的,我补充一下
首先是OT的预设物体有:
是不是看到了熟悉的Sprite等物体,首先OT这个物体是一定要一开始就拖到场景中了,它作为一个管理全局的OT物体而存在。
然后是Sprites,Sprites简单来说只有3种:不会自己主动动画的Sprite,会自己主动动画的AnimatingSprite,能填充一定区域范围的FilledSprite,这三种Sprite是直接放进场景中的,
Sprites目录下的Animation是根据SpriteAtlas或者是SpriteSheet的Texture来生成序列帧动画的,主要是设置从第几帧到第几帧是什么动画,这样子方便AnimatingSprite的调用,这些Animation就是放到场景中的OT下的Animation目录中的
Sprites目录下的SpriteAtlas和SpriteSheet都是用来管理Texture的,以后说。
话说,unity有一点我超不喜欢的就是:一个在场景中的物体带有collior 可我不知道是自己附上去的还是通过代码添加的orz
下面是附C#代码
public class CExample2 : MonoBehaviour {
/// <exclude />
public OTSprite blockPrototype; // prototype to create blocks
/// <exclude />
public OTSprite starPrototype; // prototype to create stars
bool initialized = false; // initialization indicator
// Create the objects of this demo using provided prototypes
void CreateObjects()
{
// Find the empty that will act as the block container
GameObject blocks = GameObject.Find("Blocks");
if (blocks!=null)
{
// Calculate the horizontal number of blocks for the current resolution
int c = (Screen.width - 20) / 85;
// Calculate horizontal center spacing
int s = (Screen.width - (c * 85)) / 2;
// Create bottom horizontal blocks
for (int x = 0; x < c; x++)
{
// Create a new block
OTSprite b = (Instantiate(blockPrototype.gameObject) as GameObject).GetComponent<OTSprite>();
// Set block's position
b.position = new Vector2(s + 50 + (x * 85)- (Screen.width/2), 20 - (Screen.height/2));
// Set block's name
b.name = "bottom" + x;
// Link to parent
b.transform.parent = blocks.transform;
}
// Create top horizontal blocks
for (int x = 0; x < c; x++)
{
// Create a new block
OTSprite b = (Instantiate(blockPrototype.gameObject) as GameObject).GetComponent<OTSprite>