Method for realizing cross-platform game development tool
Technical Field
The invention relates to the technical field of online game development, in particular to a method for realizing a cross-platform game development tool.
Background
The Mac OS system is a system dedicated to the apple personal computer, and cannot be normally installed and used in a general PC. The Darwin-based Mac OS X system enhances the stability, performance and responsiveness of the Mac OS system, takes full advantage of dual processors through symmetric multiprocessing, provides unparalleled 2D, 3D and multimedia graphics capabilities, and a wide range of font support and integrated PDA functionality. Mac OS X can support almost all Mac OS 9 applications through the Classic environment, and the intuitive Aqua user interface enables the usability of the Mac OS system to reach a brand new level.
The Windows system developed by Microsoft is the operating system which has the most users and the strongest compatibility in the world at present. The earliest Windows operating systems were introduced in 1985, when the operating system Windows1.0 was a DOS kernel based operating system. Windows1.0 improves Microsoft Disk Operating Systemm (MS-DOS) over the Microsoft past command code system. Microsoft Windows is an operating system of a color interface, supports a keyboard and mouse function, and a default platform consists of a taskbar and a desktop icon. The taskbar consists of a display of running programs, a "start" menu, time, quick launch bar, input methods, and the lower right tray icon. The desktop icon is a way to enter the program, and the default desktop icon is "my computer", "my document", "recycle bin", and the like. In addition, the desktop also displays an "Internet Explorer" icon carried by the system.
With the decrease of the global market share of the Windows system and the increase of the global market share of the Mac OS system, the game software developers at present need to respectively develop different versions for their products on the Windows system and the Mac OS system, which consumes a lot of manpower and material resources, thereby resulting in an excessively high cost of game software development. Therefore, a solution of a cross-platform game development tool is urgently needed to realize the application of the same version of game software in a Windows system and a Mac OS system so as to reduce the development cost of products.
At present, various cross-platform game development tools are available in the market, foreign U3D uses scripts and built-in virtual machines, and domestic technical teams use Flash, JAVA and Html5 to realize the application of the same version of game software in different operating systems. However, the cross-platform game development tools existing in the prior art have the following problems:
firstly, only C + + is used for developing a cross-platform game development tool, the rendering efficiency of the cross-platform game development tool is high, but alternatives for developing the cross-platform game development tool by using C + + are few, the cost is high, and the period is long;
secondly, only C #, JAVA and Html5 are used for developing a cross-platform game development tool, the cost is low, the period is short, and the rendering efficiency of the cross-platform game development tool is low.
Disclosure of Invention
In order to solve the above problems, the present invention provides a method for implementing a cross-platform game development tool, and C + + and C # are used to develop the cross-platform game development tool so that the same version of software product can be flexibly applied to a Windows system and a Mac OS system.
The invention provides a method for realizing a cross-platform game development tool, which comprises the following steps:
a rendering engine realized by C + + is used as a bottom layer structure of the cross-platform game development tool to support the logic and rendering of the cross-platform game development tool;
creating a C + + function packaging class library and realizing the rendering of a cross-platform game development tool;
automatically generating an interface technology/manual handwriting compilation by applying C + + and C #, and converting the C + + function packaging class library into a C # function packaging class library;
the main body interface and the functional logic of the cross-platform game development tool are realized by using C #;
and calling a C # function packaging class library and a main body interface and function logic of the cross-platform game development tool realized by using C # through a P/Invoke technology.
Further, the creating of the C + + function package library and the rendering of the cross-platform game development tool are specifically:
creating a C + + function packaging class library, simplifying and packaging classes of software products aiming at editing functions provided in a cross-platform game development tool, and providing an interface more suitable for developing the cross-platform game development tool;
and creating a visualization rendering area aiming at different platforms by using a cross-platform synchronization method.
Further, the method using cross-platform synchronization creates a visualized rendering area for different platforms, specifically:
the GTK calls an API of an operating system to create a graphical interface window of a game scene in the UI editor;
and calling a cross-platform graphic library by the UI editor, and rendering the game scene in the graphic interface window by the cross-platform graphic library.
Preferably, the cross-platform graphics library is OPENGL.
Preferably, the rendering engine implemented by the application C + + is a cross-platform game engine Cocos2d-x or Orge or KlayGE.
Further, under the MAC platform, the development of C # is supported by mono.net, and the compilation of C + + is supported by LLVM.
Furthermore, the development of C # is supported by using Microsoft.net under a Windows platform, and the compilation of C + + is supported by using VC + +.
The beneficial technical effects of the invention are as follows:
the implementation method of the cross-platform game development tool provided by the invention simultaneously uses C + + and C # to develop the cross-platform game development tool so that the software product of the same version can be flexibly applied to a Windows system and a Mac OS system. The C + + is used for realizing complex and efficient rendering, and the C # is used for realizing simple UI (user interface) and functional logic, so that the rendering efficiency of the cross-platform game development tool is ensured, and the game development cost is reduced.
Drawings
Fig. 1 is a schematic flowchart of an implementation method of a cross-platform game development tool according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and should not be construed as limiting the scope of the invention.
As shown in fig. 1, the embodiment takes a particle special effect system as an example, and provides a method for flexibly applying the same version of particle special effect system to a Windows system and a Mac OS system, which includes the following steps:
firstly, a rendering engine realized by C + + is used as an underlying structure of the cross-platform game development tool to support the logic and rendering of the cross-platform game development tool. And constructing a particle system in a rendering engine, ensuring that the particle system can normally render 2D materials or 3D models, and compiling an engine library.
The rendering engine implemented by C + + here may be cross-platform game engines Cocos2d-x, Orge, KlayGE, or other rendering engines that can be implemented by C + +.
Secondly, creating a C + + function packaging class library and realizing rendering of a cross-platform game development tool, specifically:
creating a C + + function packaging class library, simplifying and packaging classes of the particle special effect system aiming at an editing function provided in a cross-platform game development tool, and providing necessary particle objects and interface methods, such as particle initialization, particle resource loading, particle playing, pausing and stopping;
using a cross-platform synchronization method, creating a visual rendering area for different platforms, specifically:
the GTK calls an API of an operating system to create a graphical interface window of a game scene in the UI editor;
the GTK is a cross-platform graphic cross-platform game development kit, and may also be referred to as a general graphic library with powerful functions and flexible design. It supports the creation of Graphical User Interface (GUI) based applications, from which many ready building blocks for creating a GUI can be found. The method is one of mainstream development cross-platform game development tools for developing the application program of the graphical interface under GNU/Linux, and is also suitable for a Windows system or a Mac system.
Specifically, under the Windows system, the GTK calls an API of the Windows system to create a graphical interface window of a game scene in a UI editor; under the Mac system, the GTK calls an API of the Mac system to create a graphical interface window of a game scene in a UI editor; however, the embodiments of the present invention are not limited to these two operating systems, and the operating systems that can implement the embodiments of the present invention are all suitable.
And calling the cross-platform graphic library by the UI editor, and rendering the game scene in the graphic interface window created by the GTK by the cross-platform graphic library.
In the embodiment of the invention, the cross-platform graphics library is OpenGL.
And thirdly, automatically generating the corresponding C # class from the C + + functional packaging class library by using a C + + and C # automatic generation interface technology, creating a C # packaging project, loading the automatically generated C # class, and compiling into a C # functional packaging class library.
In the embodiment of the invention, manual handwriting compilation can be adopted to replace the C + + and C # automatic generation interface technology.
And fourthly, realizing a main body interface and functional logic of the cross-platform game development tool by using the C #, wherein the main body interface and the functional logic comprise the creation of particles, the editing of particle attributes and the serialization related business logic of particle data files.
And fifthly, calling the C # function packaging class library generated in the third step by using C # through a P/Invoke technology, realizing a main interface and function logic of the cross-platform game development tool by using C # in the fourth step, creating a packaging object of the particle, loading a default particle resource, setting the particle to be in a playing state, and then starting custom editing operation on the particle object.
In this embodiment, for different platforms, different components are used as development and execution environments of the cross-platform game development tool: under the MAC platform, using Mono.net to support the development of C #, and using LLVM to support the compilation of C + +; and the development of C # is supported by Microsoft.net under a Windows platform, and the compilation of C + + is supported by VC + +.
Net is a project hosted by Novell corporation. The goal of this project is to create a series of Net tools that conform to the standards ECMA (Ecma-334 and Ecma-335), including a C # compiler and common Language execution platform CLP (common Language platform). Net projects, unlike microsoft, can run not only on Windows platforms, but also on Linux, FreeBSD, Unix, Mac OS X, Solaris, and other platforms.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, it should be noted that, for those skilled in the art, many modifications and variations can be made without departing from the technical principle of the present invention, and these modifications and variations should also be regarded as the protection scope of the present invention.