A kind of implementation method of cross-platform development of games instrument
Technical field
The present invention relates to network game development technical field, and in particular to a kind of implementation method of cross-platform development of games instrument.
Background technology
Mac
OS systems are Macintosh dedicated system, cannot be installed in ordinary PC and used under normal circumstances.Mac based on Darwin
OS system X enhances stability, performance and the responding ability of Mac OS systems, it can give full play to the advantage of dual processor by symmetric multi-processors technology, there is provided impayable 2D, 3D and multimedia graphic performance and extensive font are supported and integrated PDA functions.Mac OS X can almost support all of application programs of Mac OS 9 by Classic environment, and the intuitively Aqua user interfaces that it has make the ease for use of Mac OS systems reach a brand-new level again.
The Windows systems of Microsoft exploitations are that user is most in the world at present, and the most strong operating system of compatibility.Earliest Windows operating system was just proposed from 1985, and the operating system Windows1.0 for releasing at that time is the operating system based on DOS kernels.Windows1.0 improves the conventional command code system Microsoft Disk Operating Systerm of Microsoft(MS-DOS).Microsoft
Windows is the operating system of color interface, supports key mouse function, and the platform of acquiescence is made up of taskbar and desktop icons.Taskbar is by showing the program being currently running, the Start menu, the time, quickly starting column, input method and lower right corner tray icon and constitute.And desktop icons are the approach for entering program, default desktop icon has " my computer ", " my document ", " recycle bin " etc..In addition, desktop can also show that system carries " Internet
Explorer " icons.
With the lifting of the world market share of the decline and Mac OS systems of the world market share of Windows systems, present merchants for game software development needs to be the product of oneself version that application and development is different in Windows systems with Mac OS systems respectively, substantial amounts of manpower and materials are consumed, so as to the high cost for causing Games Software to develop.Therefore it is badly in need of a kind of solution of cross-platform development of games instrument to realize same version Games Software in Windows systems and Mac OS systematic differences, to reduce the development cost of product.
At present, various cross-platform development of games instruments have been occurred in that on the market, and external U3D has used script and built-in virtual machine, and domestic technical team realizes application of the same version Games Software in different operating system using Flash, JAVA and Html5.However, there is problems with cross-platform development of games instrument present in prior art:
One is that cross-platform development of games instrument is only developed using C++, and cross-platform development of games instrument rendering efficiency is high, but few using the alternative that C++ develops cross-platform development of games instrument, and high cost, the cycle is long;
Next to that only use C#, JAVA, Html5 to develop cross-platform development of games instrument, low cost, cycle is short, but cross-platform development of games instrument rendering efficiency is low.
The content of the invention
To solve the above problems, the invention provides a kind of implementation method of cross-platform development of games instrument, while developing cross-platform development of games instrument using C++ and C# so that the software product of same version can be flexibly applied in Windows systems and Mac OS systems.
The invention provides a kind of implementation method of cross-platform development of games instrument, methods described includes:
Using the rendering engine of C++ realizations as the fabric of cross-platform development of games instrument, the logical sum of cross-platform development of games instrument is supported to render;
Create C++ function packages class libraries and realize rendering for cross-platform development of games instrument;
Interfacing/artificial hand-written compiling is automatically generated using C++ and C#, C++ function package class libraries, C# function package class libraries is converted into;
Main body interface and the function logic of cross-platform development of games instrument are realized using C#;
By P/Invoke technologies, call C# function packages class libraries using C# and use main body interface and the function logic of the cross-platform development of games instrument of C# realizations.
Further, the establishment C++ function packages class libraries and rendering for cross-platform development of games instrument is realized, specially:
C++ function package class libraries is created, for the editting function provided in cross-platform development of games instrument, the class to software product carries out simplifying encapsulation, there is provided be more suitable for the interface of cross-platform development of games too development;
Using cross-platform synchronous method, for different platforms, establishment is visual to render region.
Further, described to use cross-platform synchronous method, for different platforms, establishment is visual to render region, specially:
The API of GTK call operation systems creates the graphical interface window of scene of game in UI editing machines;
UI editing machines call cross-platform shape library, and scene of game is rendered in the graphical interface window by the cross-platform shape library.
Preferably, the cross-platform shape library is OPENGL.
Preferably, the rendering engine that the application C++ is realized is cross-platform game engine Cocos2d-x or Orge or KlayGE.
Further, the exploitation of C# is supported under MAC platforms using Mono.net, the compiling of C++ is supported using LLVM.
Further, the exploitation of C# is supported under windows platform using Microsoft.net, the compiling of C++ is supported using VC++.
Advantageous Effects of the invention are:
The implementation method of a kind of cross-platform development of games instrument that the present invention is provided, while developing cross-platform development of games instrument using C++ and C# so that the software product of same version can be flexibly applied in Windows systems and Mac OS systems.Realize that complexity is efficiently rendered using C++, simple UI interfaces and function logic are realized using C#, the rendering efficiency of cross-platform development of games instrument had both been ensure that, while also reducing development of games cost.
Brief description of the drawings
Fig. 1 is a kind of schematic flow sheet of the implementation method of cross-platform development of games instrument provided in an embodiment of the present invention.
Specific embodiment
In order to make the purpose , technical scheme and advantage of the present invention be clearer, below in conjunction with drawings and Examples, the present invention will be described in further detail.It should be appreciated that specific embodiment described herein is used only for explaining the present invention, it is impossible to be interpreted as the restriction to specific protection domain of the invention.
As shown in figure 1, the present embodiment is by taking particle effect system as an example, provides a kind of particle effect system that can make same version and be flexibly applied to method in Windows systems and Mac OS systems, comprise the following steps:
First, the logical sum of cross-platform development of games instrument is supported to render as the fabric of cross-platform development of games instrument using the rendering engine of C++ realizations.ParticIe system is built in rendering engine, it is ensured that particIe system can normally render 2D materials or 3D models, compiler engine storehouse.
Here the rendering engine that use C++ is realized, can be cross-platform game engine Cocos2d-x, Orge, KlayGE, or other rendering engines that C++ can be used to realize.
2nd, create C++ function packages class libraries and realize rendering for cross-platform development of games instrument, specially:
C++ function package class libraries is created, for the editting function provided in cross-platform development of games instrument, the class to particle effect system carries out simplifying encapsulation, necessary particle object and interface method, such as the initialization of particle, the resource loading of particle are provided, the broadcasting of particle, pause and stopping;
Using cross-platform synchronous method, for different platforms, establishment is visual to render region, specially:
The API of GTK call operation systems creates the graphical interface window of scene of game in UI editing machines;
Wherein, GTK is a kind of cross-platform development of games kit of cross-platform figure, it is also possible to which referred to as One function is powerful, a flexible design general graphical storehouse.It supports to create and is based on graphic user interface(Graphical
User Interface, hereinafter referred to as GUI)Application program, can be found for creating the building block that many of GUI is already prepared to from this cross-platform development of games kit.It is that the main flow of the application program that graphical interfaces is developed under GNU/Linux develops one of cross-platform development of games instrument, is also applied for Windows systems or Mac systems.
Specifically, under Windows systems, GTK calls the API of Windows systems that the graphical interface window of scene of game is created in UI editing machines;Under Mac systems, GTK calls the API of Mac systems that the graphical interface window of scene of game is created in UI editing machines;But the embodiment of the present invention is not limited to both operations system, as long as the operating system that can complete the embodiment of the present invention is all suitable for.
UI editing machines call cross-platform shape library, and scene of game is rendered in the graphical interface window that GTK is created by cross-platform shape library.
In the embodiment of the present invention, cross-platform shape library is OpenGL.
3rd, interfacing is automatically generated using C++ and C#, C++ function package class libraries is automatically generated corresponding C# classes, create the encapsulation engineering of C#, the C# classes that loading is automatically generated are compiled into C# function package class libraries.
In the embodiment of the present invention, it would however also be possible to employ artificial hand-written compiling automatically generates interfacing replacing C++ and C#.
4th, realize main body interface and the function logic of cross-platform development of games instrument using C#, including particle establishment, the editor of particle property, the serializing related service logic of particle data file.
5th, by P/Invoke technologies, main body interface and the function logic of cross-platform development of games instrument are realized in C# function packages class libraries and four steps that generation in above-mentioned third step is called using C# using C#, create the encapsulated object of particle, and load the particle resource of acquiescence, setting particle is broadcast state, then starts the self-defined edit operation to particle object.
In the present embodiment, for different platforms, the exploitation as cross-platform development of games instrument and running environment using different components:The exploitation of C# is supported under MAC platforms using Mono.net, the compiling of C++ is supported using LLVM;The exploitation of C# is supported under windows platform with Microsoft.net, the compiling of C++ is supported using VC++.
Wherein, Mono.net is a project presided over by novell, inc..The target of the project is to create a series of .Net instruments for meeting standard ECMA (Ecma-334 and Ecma-335), including C # compilers and common language perform platform CLP (Common
Language Platform)..Net from Microsoft is different, and Mono.net projects can not only run on windows platform, can also run on the platforms such as Linux, FreeBSD, Unix, Mac OS X and Solaris.
The above is only the preferred embodiment of the present invention; it is not intended to limit the invention; it should be understood that; for those skilled in the art; on the premise of the technology of the present invention principle is not departed from; some improvement and modification can also be made, these are improved and modification also should be regarded as protection scope of the present invention.