1. 进入console目录
cd /Users/apple/Documents/MyArchitecture/Cocos2d-x/Framework/cocos2d-x-3.4/tools/cocos2d-console/bin
2. 编写shell脚本存放在自己的程序目录
newproject.sh
#!/bin/bash echo Please Input Project Name: read PROJECT_NAME echo Please Input Package Name: read PACKAGE_NAME #enter directory cd /Users/apple/Documents/MyArchitecture/Cocos2d-x/Train #create Project PROJECT_DIR="/Users/apple/Documents/MyArchitecture/Cocos2d-x/Train" echo $PROJECT_DIR cocos new $PROJECT_NAME -p $PACKAGE_NAME -l cpp -d $PROJECT_DIR
3. 执行shell脚本
chmode +x
/Users/apple/Documents/MyArchitecture/Cocos2d-x/newproject.sh
4. 如果发生错误怎么修复
cocos: command not found
source ~./bash_profile