【发布时间】:2014-01-25 21:06:33
【问题描述】:
我正在尝试在 Unity 3D 中创建 2D 游戏,但出现以下错误:
解析错误:只有assignments、call、increment、decrement、await和new对象表达式可以作为语句使用
我已按照指南进行操作,但仍然出现错误。
我的代码:
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour {
public float maxSpeed = 10f;
bool facingRight = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
float move = Input.GetAxis ("Horizontal");
rigidbody2D.velocity = new Vector2 (move * maxSpeed, rigidbody2D.velocity.y);
if(move > 0 &&! facingRight){
Flip ();
}
else if(move < 0 && facingRight){
Flip ();
}
}
void Flip () {
facingRight != facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
【问题讨论】:
标签: c# unity3d computer-science game-engine