赞
踩
调试背景
2D游戏的制作最重要的是层的设置
先设置两个层①Layers②Edit Layers③Sorting Layers添加两个层BackGround和Front
调试大雁
创建2D object改名BackGround设置背景图片修改为BackGround 0层
创建2D object添加大雁图片Ctrl+6,保存,把大雁动态模型全选,插入。调整时间可以看起来舒服,调整所在层为BackGround 1层
添加脚本使大雁从屏幕右边开始飞入左边飞出
publicclassSwanFly : MonoBehaviour {
//天鹅起飞的位置
privateVector3 startPosition;
publicfloat speed;
// Use this for initialization
void Start () {
Debug.Log("屏幕的宽度" + Screen.width);
Debug.Log("屏幕的高度" + Screen.height);
Vector3 screenSize = Camera.main.ScreenToWorldPoint(newVector3(Screen.width, Screen.height, 0));
float swanExtentsX = transform.GetComponent<Renderer>().bounds.extents.x;
startPosition = newVector3(screenSize.x + transform.position.y, transform.position.z);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。