首页 > 编程语言 > 详细

cocos3 python脚本建立类文件

时间:2014-12-11 00:06:52      阅读:352      评论:0      收藏:0      [点我收藏+]

以前看过一本关于精简工作内容的书,要把工作中重复的东西都简化

今天我就来简化cocos3建立.h文件和.cpp文件

ClassName="TestSprite"
Type="Sprite"

#.h file write
file = open(ClassName+.h, w)
str=‘‘‘#pragma once
#include "cocos2d.h"
USING_NS_CC;

class ClassName:public Type
{
public:
    virtual bool init();
    CREATE_FUNC(ClassName);
};
‘‘‘
str=str.replace("ClassName",ClassName)
str=str.replace("Type",Type)
file.write(str)
file.close()


#.cpp file write
file = open(ClassName+.cpp, w)
str=‘‘‘#include "ClassName.h"

bool ClassName::init()
{
    if(!Type::init())
    {
        return false;
    }

    
    return true;
}
‘‘‘
str=str.replace("ClassName",ClassName)
str=str.replace("Type",Type)
file.write(str)
file.close()

 

cocos3 python脚本建立类文件

原文:http://www.cnblogs.com/yufenghou/p/4156596.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!