sublime下用快捷键直接运行cocos2dx项目

来源:互联网 发布:linux at 编辑:程序博客网 时间:2024/05/21 10:41

sublime 可以通过配置.sublime-build文件来构建编译选项或者执行外部脚本

项目是用lua开发的,所以需要经常在decode和sublime之间切换,后来想到一个办法就是通过python来启动项目,具体步骤如下:

以下为.sublime-build的代码,将其命名为带.sublime-build后缀的名字,放在sublime user文件夹下,其中xx.py为python脚本的绝对路径

{
    "cmd": ["python", "-u", "xx.py"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.lua"
}

以下为python脚本启动项目的代码,其中xx.exe为执行文件exe相对于当前脚本目录的相对目录,同理xx/Resources也是相对目录

import ctypes

import os,sys

handler = None
operator = "open"
fpath = os.getcwd() + "xx.exe"
param = None
dirpath = os.getcwd() + "xx/Resources"
ncmd = 1
shell32 = ctypes.windll.LoadLibrary("shell32.dll")

shell32.ShellExecuteA(handler,operator,fpath,param,dirpath,ncmd)

这些工作完毕以后,就可以在sublime下打开lua文件,直接快捷键f7即可运行项目


sublime同样支持API提示和补全,具体请参看http://blog.csdn.net/wtyqm/article/details/9346863


0 0