CN104866291A - Android-based 2D mobile game engine - Google Patents
Android-based 2D mobile game engine Download PDFInfo
- Publication number
- CN104866291A CN104866291A CN201410062630.1A CN201410062630A CN104866291A CN 104866291 A CN104866291 A CN 104866291A CN 201410062630 A CN201410062630 A CN 201410062630A CN 104866291 A CN104866291 A CN 104866291A
- Authority
- CN
- China
- Prior art keywords
- animation
- game
- redundancy
- android
- class
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Processing Or Creating Images (AREA)
Abstract
The invention designs various game engine modules required by mobile game development and provides a method for solving 2D animation redundancy to solve the problem of 2D animation redundancy in combination with an XFL document provided by Flash. In order to solve the problem of image resizing blur and system hardware limitation of Android, a linear interpolation correcting algorithm based on the gradient minimum criterion is improved, adjacent pixel correlation judgment is introduced on the basis of an original algorithm, and high-frequency components of pixel marginal information are reserved. The engine has functions of improving the game development efficiency, reducing resources required by games and improving the image resizing display effect. The figure is a game engine function module figure.
Description
Technical field:
Computer Science and Technology;
Background technology:
The technology that the present invention relates to: Android multi-screen adaptation technique, Android cartoon technique, Android image processing techniques etc.
Summary of the invention:
The present invention devises the modules of the game engine required for mobile phone games exploitation.For the problem of 2D animation redundancy, in conjunction with the XFL document that Flash provides, propose a kind of method solving 2D animation redundancy.For the fuzzy problem limited with system hardware of Android epigraph convergent-divergent, improve the linear interpolation correction algorithm based on gradient minimum criteria, the basis of former algorithm introduces neighbor correlativity and judges, to retain the high fdrequency component of pixel edge information.This engine has the function that can improve development of games efficiency, reduce game resource requirement, improve the display effect of image scaling.
Accompanying drawing illustrates:
Accompanying drawing 1 is game engine functional block diagram.
Accompanying drawing 2 is the whole service constitutional diagram of game.
Accompanying drawing 3 is GameActivity class figure.
Accompanying drawing 4 is game overall logic sequential chart.
Accompanying drawing 5 is scene of game administration module class graph of a relation.
Accompanying drawing 6 is whole animation de-redundancy process.
Embodiment:
For realizing the functional requirement of game engine, game engine is divided into the expansion that different modules contributes to the separate of modules and later function, the whole functional module of game engine Idoodle divides as accompanying drawing 1.Which show game engine primarily of scene management module, animation administration module, image display, resource management module, event response module, overall logic control module composition.
Scene management module: this module provides the management of game entity scene is the response of each scene Distribution Events and drawing command.
Animation administration module: the flexible control being responsible for the parsing of animate resources file, the generation of animation and animation.This module uses 2D frame animation to provide simple operations for developer.
Image display: this module in charge plays up the management of thread and the encapsulation of OpenGL ES drawing function.The drafting of image in main process game, comprises the reference object setting up OpenGL ES, provides and plays up the synchronous of thread and UI thread, set up draw spirit and grid drawing image.
Resource management module: be responsible for comprising to all kinds of resource files of Android phone the process that the loading of picture resource file, voice resource file etc. and operation provide convenience.
Event response module: be responsible for the management of the various events of android system and corresponding process is provided, comprising key-press event, slip event, the process of Sensor Events.
Overall logic control module: be responsible for organizing modules, co-ordination that modular organisation is got up.
Overall logic control module manages the response of whole game body with mutual.Game body is to self abstract of game, and it is abstract that it comprises game state and state transition rules thereof, and it is abstract that it also comprises game running logic.Game is once be activated, and except game over or pausing operation, game is in running status always and is constantly cycled to repeat identical action.
Accompanying drawing 2 is the whole service constitutional diagram of game.The principal states of game has startup state, run mode, time-out state, stops state.In order to each state of management game well, the overall logic of the present invention's design controls to be controlled by GameActivity class, this Similar integral is in Activity and contain the image rendering class GameGraphics of game, file processing class GameFiles, event handling class Gamelnput, acoustic management class GameAudio, interface GameListener is monitored in game.Activity is one of four large assemblies of providing of Android, and abstract method onStart () wherein, onPause () etc. provides the response interface of each state of game.
Accompanying drawing 3 is for showing the relation of GameActivity class and other main class.GameActivity inherits in Activity, is the establishment entrance of games; GameGraphics, for creating playing up thread and encapsulating based on the relevant drawing function of OpenGL ES of image, draws interface easily to provide; GameAudio is the broadcasting for managing Android device audio frequency, provides simple audio calls interface; The file handle that GameFiles creates for quoting Android device, manages and loads by such file leaving Android device diverse location in, provide succinct method of calling to the operation of file; Gamelnput for the treatment of the operation response of Android device event, to provide each scene to the response process of event; GameListener, for creating the entity part of game, provides the management of the entrance of game entity part and each scene of playing, and is abstract to game entity.
In GameActivity, member function initiai ize (GameListener listener) accepts the image parameter of a game entity and the establishment in the inside of function to modules object, exist as a reference identification, to provide calling of outside game entity GameListener after creating these objects.Wherein, graphics object is used for the drafting of image rendering, and graphics is the object achieving Renderer interface, Renderer be Android for GLSurfaceView so that the common interface that provides of the APl accessing OpenGL ES.GLSurfaceView is the view class of Android provide for carrying out playing up in non-UI thread, and therefore graphics is actual is play up thread object by UI thread creation independent logical.
Accompanying drawing 4 is game overall logic sequential chart, illustrates game developer from creating the sequential relationship of game to game theme operation.Each logical message in figure is explained as follows:
Message 1: create game by inheriting in the GameActivity of Activity, GameActivity object is in the UI thread of game.
Message 2: the entity object creating a game in UI thread, this carries out the realization of the logical abstraction of the maintenance of the game logic world and tissue to liking user, provide the management of the various scenes in game.
Message 3: after the entity object creating game, the event handling object creating the graph rendering object required for game, game file operand, game sound operand and play.Graph rendering object provides special thread of playing up and draws, and when can prevent android system from carrying out great amount of images drafting like this in UI thread, occurs the seemingly-dead phenomenon that game is waited for.
Message 4: image rendering object can call GameListener class entity object when surfaceCreate carries out the loading of resource.
Message 5: game entity object passes through game file object load document resource as picture resource, text resource, binary file etc.
Message 6: game entity object loads corresponding audio files by sound operand.
Message 7: the incoming event of image rendering object accepting device, the event in the onFrame () function playing up thread in processing queue event.
Message 8: each scene that the process of event is distributed to game entity object by image rendering object processes, carries out unified renewal rewards theory after each scene process self event complete.
Message 9: after the state of game entity object upgrades, the drawing function of image rendering object reference game entity object carries out the drafting of image, is shown on screen.
In game play, continuous repetition message 7-9 process, has come real-time response and the display of game.Developer only needs management game entity object, complete the inter-process of each scene in game, call the loading that resource management interface carries out resource, the process of event response, call corresponding drawing function interface and carry out drawing image etc. and just can carry out good control and realization to game.
Scene of game administration module manages with being responsible for each scene of game entity part.This module is the management to the game logic world, be responsible for the maintenance of various thingness state in the game loading of resource requirement, gaming world, gaming world various objects to the response etc. of incoming event.Gaming world is divided into each different scenes, contributes to the trustship safeguarding respective state and resource, safeguard thinking and shirtsleeve operation method clearly for game developer provides.
Scene of game administration module class graph of a relation such as accompanying drawing 5, MGame is the entity class of games, and such is responsible for the loading of game resource, event handling and distribution, and the drafting of each scene and management.This Similar integral GameListener interface, InputProcessot interface, GestureListener interface, comprise simultaneously achieve drawing function smart object spritebatch, the contextual reference identification of Android device, scene of game reference identification.GameListener interface be used in GameActivity register game entity quote interface, for from game UI thread contexts to game entity part; InputProcessor and GestureLi stener interface is for realizing the process of game entity to the response of event message and slip gesture; Spritebatch is to liking the object playing up function that encapsulates game, and for the drafting of image in scene, the design of this object is specifically introduced in image display; Context identifies about the device context of Android, visits resource for using Android self application programming interfaces; Screen to as if a reference identification of game Scene, game entity, when carrying out case distribution and drawing display, calls this and quotes and visiting ask current scene.Screen class is the abstract representation of scene of game, and each scene of game may comprise a specific game logic world MWorld class or be convenient to carry out managing to the element of scene the logical layer MLayer class of Further Division.The response of event and Rendering operations carry out being distributed to Screen class again to MWorld class and MLayer class from Game class, finally arrive the entity elements MObject class of game.The well arranged like this game developer of contributing to divides each scene in game arbitrarily, to describe the logic of game easily, processes the operation and management arranging can full out realize scene of game according to this simultaneously.
Image display comprises playing up class and using the encapsulation class SpriteBatch of OpenGL ES graphing in game.Play up class establishment and play up thread, set up OpenGL ES object reference.The complex operations of the encapsulation class SpriteBatch packaging bottom layer OpenGL ES function of graphing, the 2D drawing interface of providing convenience, realizes high performance rendering effect by calling simple function of drawing.
Animation mainly can generate and use in order to developer the 2D animation designed in a convenient way, and provides the de-redundancy process of motion picture, and still can use the raw animation that Android provides during use, both are independent of each other mutually.The main class of animation is MFAnimation, and such completes parsing, the generation of animation file and controls.
KeyEvent under event response resume module Android platform, screen touch event, Sensor Events, shock event.Event response process is unified to be encapsulated in GameInput class, such has been separated event process in the view, the process unification of event is quoted by the event handling object input in game entity, again event is distributed to respectively each scene in game entity, be convenient to the response of scene of game to event, when the process of Android to event changes time, only need the realization revising Gamelnput class, game itself does not need amendment.
Resource management module is responsible for sound under Android platform, the loading of picture resource and use.For convenience of the access of resource file, the path of design four kinds of access resources files: internal file, extendfile, absolute path file, local path file.Internal file is the file under the asserts catalogue provided by Android; Extendfile is the file put on a memory card that Android provides; Absolute path file is the complete path name file on Android; Local path file is the relative path file under present procedure root directory.Android resource is conducted interviews by AssetManager, and AssetManager is responsible for the reading of the data of resource file.For convenience of the use of voice resource, picture resource, carry out point other realization to these two parts, the access of other resource file directly can be accessed by AssetManager.
1. the design and implimentation of sound management module
Sound under Android platform is divided into two classes: the audio files resource of Sound and Music, Sound type is little, reproduction time is short; The audio files resource of Music type is large, reproduction time is long.The audio files of Sound type is undertaken managing and playing by SoundPool, and the audio files of Music type is undertaken managing and playing by MediaPlayer.In game engine Idoodle, the management and of voice resource module is unified has been encapsulated in GameAudio class.
2. picture management module design and implimentation
For providing the realization of drawing in image display, picture resource is unified to be encapsulated in Texutre, exists in the mode of texture.Texture class is one and includes image pixel data, and the texture encapsulating OpenGL ES commonly uses the class of operation.For improving the rendering speed of image, once submitted to by the picture simultaneously needing to play up, devise TextureRegion class, such is the class comprising Texture reference object.Picture resource corresponding to Texture class comprises the little picture resource that multiple needs are played up, and TextureRegion class is quoting little picture resource.
Android animation de-redundancy: whole animation de-redundancy process is as accompanying drawing 6, first Flash CS5 is used to make corresponding animation, using a class animation as one group, third-party conjunction figure software is used little figure all in one group of animation to be synthesized a figure greatly, obtain the location expression information of the large figure at little figure place simultaneously, then by analyzing DOMDocument.xml file and extract corresponding information and in conjunction with the relevant information of conjunction figure, obtain one and include the large figure of all motion pictures and all descriptors of each animation, animation is finally used to realize parsing and the control of animation.By to the analysis of animation de-redundancy and reality service condition in the project, animate resources approximately can remove the picture redundancy of 70%.
Based on the improvement of the linear interpolation correction algorithm of gradient minimum criteria, the basis of former algorithm introduces neighbor correlativity and judges, to retain the high fdrequency component of pixel edge information.
1. determine three points nearest with interpolation point, as the selected element of correlativity point.
2. determine the pixel value of 2 that correlativity is large, as the pixel value of interpolation reference point.
3. determine the pixel value of 2 that correlativity is large, as the pixel value of interpolation reference point.
By One-Dimensional Extended to two-dimensional case: according to above interpolation calculation step, first original image is realized horizontal direction amplification according to pantograph ratio and obtain intermediate image, and then intermediate image is amplified according to vertical direction, obtain final image.
Claims (3)
1. the feature based on the mobile phone 2D game engine of Android:
(1) a kind of method solving 2D animation redundancy is proposed;
First Flash CS5 is used to make corresponding animation, using a class animation as one group, third-party conjunction figure software is used little figure all in one group of animation to be synthesized a figure greatly, obtain the location expression information of the large figure at little figure place simultaneously, then by analyzing DOMDocument.xml file and extract corresponding information and in conjunction with the relevant information of conjunction figure, obtain one and include the large figure of all motion pictures and all descriptors of each animation, finally use animation to realize parsing and the control of animation.By to the analysis of animation de-redundancy and reality service condition in the project, animate resources approximately can remove the picture redundancy of 70%.
(2) modified is based on the linear interpolation correction algorithm of gradient minimum criteria;
1) three points nearest with interpolation point are determined, as the selected element of correlativity point.
2) pixel value of 2 that correlativity is large is determined, as the pixel value of interpolation reference point.
3) pixel value of 2 that correlativity is large is determined, as the pixel value of interpolation reference point.
By One-Dimensional Extended to two-dimensional case: according to above interpolation calculation step, first original image is realized horizontal direction amplification according to pantograph ratio and obtain intermediate image, and then intermediate image is amplified according to vertical direction, obtain final image.
2. according to the 2D animation de-redundancy technology that right 1 requires.
3. the modified required according to right 1 is based on the linear interpolation correction algorithm of gradient minimum criteria.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410062630.1A CN104866291A (en) | 2014-02-24 | 2014-02-24 | Android-based 2D mobile game engine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410062630.1A CN104866291A (en) | 2014-02-24 | 2014-02-24 | Android-based 2D mobile game engine |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104866291A true CN104866291A (en) | 2015-08-26 |
Family
ID=53912144
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410062630.1A Pending CN104866291A (en) | 2014-02-24 | 2014-02-24 | Android-based 2D mobile game engine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104866291A (en) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105553708A (en) * | 2015-12-14 | 2016-05-04 | 江苏名通信息科技有限公司 | Mobile game platform management system |
CN105630507A (en) * | 2015-12-29 | 2016-06-01 | Tcl集团股份有限公司 | Method and device for drawing WebView control interface |
CN105653267A (en) * | 2015-12-28 | 2016-06-08 | 心动网络股份有限公司 | Electronic device and data processing method |
CN107678804A (en) * | 2017-08-22 | 2018-02-09 | 腾讯科技(深圳)有限公司 | Behavior performs method and apparatus, storage medium and electronic installation |
CN109828791A (en) * | 2018-12-28 | 2019-05-31 | 北京奇艺世纪科技有限公司 | A kind of animation playing method, terminal and computer readable storage medium |
CN110300332A (en) * | 2019-06-18 | 2019-10-01 | 南京科源信息技术有限公司 | A kind of game loading method and system based on IPTV |
-
2014
- 2014-02-24 CN CN201410062630.1A patent/CN104866291A/en active Pending
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105553708A (en) * | 2015-12-14 | 2016-05-04 | 江苏名通信息科技有限公司 | Mobile game platform management system |
CN105653267A (en) * | 2015-12-28 | 2016-06-08 | 心动网络股份有限公司 | Electronic device and data processing method |
CN105653267B (en) * | 2015-12-28 | 2019-05-07 | 心动网络股份有限公司 | Electronic equipment and data processing method |
CN105630507A (en) * | 2015-12-29 | 2016-06-01 | Tcl集团股份有限公司 | Method and device for drawing WebView control interface |
CN107678804A (en) * | 2017-08-22 | 2018-02-09 | 腾讯科技(深圳)有限公司 | Behavior performs method and apparatus, storage medium and electronic installation |
CN107678804B (en) * | 2017-08-22 | 2021-04-09 | 腾讯科技(深圳)有限公司 | Behavior execution method and apparatus, storage medium, and electronic apparatus |
CN109828791A (en) * | 2018-12-28 | 2019-05-31 | 北京奇艺世纪科技有限公司 | A kind of animation playing method, terminal and computer readable storage medium |
CN110300332A (en) * | 2019-06-18 | 2019-10-01 | 南京科源信息技术有限公司 | A kind of game loading method and system based on IPTV |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN104866291A (en) | Android-based 2D mobile game engine | |
CN103562862B (en) | Global composition system | |
KR20200027004A (en) | Game rendering method, and game resource file generation method, apparatus, and device | |
EP2464093B1 (en) | Image file generation device, image processing device, image file generation method, and image processing method | |
CN106251392A (en) | For the method and apparatus performing to interweave | |
CN103914205B (en) | A kind of file thumbnail methods of exhibiting of intelligent terminal and device | |
WO2013182089A1 (en) | Object suspension realizing method and device | |
US20130198686A1 (en) | Image processing device for displaying content, content creation device, and image processing method | |
CN113411664B (en) | Video processing method and device based on sub-application and computer equipment | |
US20130063445A1 (en) | Composition System Thread | |
CN110516179A (en) | Method for rendering graph, device, electronic equipment and storage medium | |
CN104321752A (en) | Virtual surface allocation | |
CN105321142A (en) | Sampling, fault management, and/or context switching via a computer pipeline | |
US10474574B2 (en) | Method and apparatus for system resource management | |
TW201826109A (en) | Method and apparatus for page presentation | |
CN103729174A (en) | Screen capturing method and device | |
CN105190701A (en) | Primitive-based composition | |
WO2019071618A1 (en) | Image processing method and device | |
KR20210104143A (en) | Image acquisition methods, devices, servers and storage media | |
CN110443880B (en) | Image rendering method and device, storage medium and electronic equipment | |
EP4358028A1 (en) | Graphic rendering method and apparatus, and storage medium | |
WO2022247541A1 (en) | Method and apparatus for application animation linking | |
CN102193806A (en) | Method and device for updating animation | |
CN114077489A (en) | Model loading method and related device | |
US20070085853A1 (en) | Inheritance context for graphics primitives |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150826 |
|
WD01 | Invention patent application deemed withdrawn after publication |