1.访问www.painterengine.com,在左下角点击下载PainterEngine
2.解压缩PainterEngine压缩包,得到以下文件夹
3.启动visual studio 创建一个新项目
4.创建一个空项目
5.*新建一个筛选器,命名为PainterEngine(本步骤非必须)
6.将PainterEngine以下三个文件夹拖到项目文件夹中
7.因为我们开发的是windows示范程序,因此,将platform/windows文件夹拖到项目文件夹中
8.最后,将project文件夹拖到项目中
9.选中项目.然后在菜单中点击项目à属性
10.选中VC++目录à包含目录à编辑
11.将Painterengine,Painterengine/project两个文件夹位置加入包含目录
12.现在,你可以运行Painterengine程序了
13.打开PX_Application.c文件,将下面的代码复制并替换里面的代码
#include "PainterEngine_Application.h"
#include "./architecture/PainterEngine_Designer.h"
PX_Application App;
PX_FontModule fm;//中文字模
PX_Object *root,*ui_root,*designer;//根对象,ui根对象,设计器对象
//当设计器点击debug->execute时执行
//在这个函数中,将当前的UI布局保存到ui.json文件
px_void PX_Application_DesignerExport(PX_Object *pObject,PX_Object_Event e,px_void *ptr)
{
px_string string;
PX_StringInitialize(&App.runtime.mp_game,&string);
PX_DesignerExport(pObject,&string);
PX_SaveDataToFile(string.buffer,PX_strlen(string.buffer)+1,"ui.json");
PX_StringFree(&string);
return;
}
//初始化
px_bool PX_ApplicationInitialize(PX_Application *pApp,px_int screen_width,px_int screen_height)
{
//默认初始化函数
PX_ApplicationInitializeDefault(&pApp->runtime, screen_width, screen_height);
//初始化字模
PX_FontModuleInitialize(&pApp->runtime.mp_resources,&fm);
//加载字模
PX_LoadFontModuleFromFile(&fm,"gbk_18.pxf");
//创建根对象
root=PX_ObjectCreate(&pApp->runtime.mp_ui,PX_NULL,0,0,0,0,0,0);
//创建UI根对象
ui_root=PX_ObjectCreate(&pApp->runtime.mp_ui,root,0,0,0,0,0,0);
//创建设计器
designer=PX_DesignerCreate(&pApp->runtime.mp_game,&pApp->runtime.mp_ui,&pApp->runtime.mp_game,root,ui_root,PX_NULL,&fm);
//绑定设计器execute事件
PX_ObjectRegisterEvent(designer,PX_OBJECT_EVENT_EXECUTE,PX_Application_DesignerExport,PX_NULL);
//激活设计器
PX_DesignerActivate(designer);
return PX_TRUE;
}
px_void PX_ApplicationUpdate(PX_Application *pApp,px_dword elpased)
{
//更新根对象
PX_ObjectUpdate(root,elpased);
}
px_void PX_ApplicationRender(PX_Application *pApp,px_dword elpased)
{
//渲染
px_surface *pRenderSurface=&pApp->runtime.RenderSurface;
PX_RuntimeRenderClear(&pApp->runtime,PX_OBJECT_UI_DEFAULT_BACKGROUNDCOLOR);
PX_ObjectRender(pRenderSurface,root,elpased);
}
px_void PX_ApplicationPostEvent(PX_Application *pApp,PX_Object_Event e)
{
//分发事件
PX_ApplicationEventDefault(&pApp->runtime, e);
PX_ObjectPostEvent(root,e);
}
14.点击编译运行,现在,你可以运行设计器了