CN118873942A - A collision detection method, device, electronic device and storage medium - Google Patents
A collision detection method, device, electronic device and storage medium Download PDFInfo
- Publication number
- CN118873942A CN118873942A CN202411067550.5A CN202411067550A CN118873942A CN 118873942 A CN118873942 A CN 118873942A CN 202411067550 A CN202411067550 A CN 202411067550A CN 118873942 A CN118873942 A CN 118873942A
- Authority
- CN
- China
- Prior art keywords
- image object
- interface
- target
- rendering function
- function interface
- 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
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/55—Controlling game characters or game objects based on the game progress
- A63F13/57—Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game
- A63F13/577—Simulating properties, behaviour or motion of objects in the game world, e.g. computing tyre load in a car race game using determination of contact between game characters or objects, e.g. to avoid collision between virtual racing cars
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/50—Controlling the output signals based on the game progress
- A63F13/52—Controlling the output signals based on the game progress involving aspects of the displayed game scene
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/80—Special adaptations for executing a specific game genre or game mode
- A63F13/822—Strategy games; Role-playing games
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/80—Special adaptations for executing a specific game genre or game mode
- A63F13/837—Shooting of targets
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/30—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game characterized by output arrangements for receiving control signals generated by the game device
- A63F2300/308—Details of the user interface
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/80—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game specially adapted for executing a specific type of game
- A63F2300/807—Role playing or strategy games
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Theoretical Computer Science (AREA)
- Human Computer Interaction (AREA)
- Processing Or Creating Images (AREA)
Abstract
Description
技术领域Technical Field
本公开涉及碰撞检测技术领域,具体涉及一种碰撞检测方法、装置、电子设备和存储介质。The present disclosure relates to the technical field of collision detection, and in particular to a collision detection method, device, electronic device and storage medium.
背景技术Background Art
为了满足人们对精神生活的追求,能够在终端上操作的娱乐游戏应运而生,例如,基于客户端或服务器架构开发的多人在线动作游戏、角色扮演游戏、战术竞技类游戏或射击游戏等类型的游戏。其中,像素检测是游戏开发中的一项关键技术,它被用于确定游戏元素(如虚拟角色、虚拟物品、以及虚拟场景等)的像素级别的碰撞,具体可以判断某个游戏元素是否被鼠标或手指接触。现有技术中通过借助像素检测,使得游戏开发人员能够更精确地制作游戏元素对应的行为,从而提升游戏的真实感和玩家的游戏体验。In order to meet people's pursuit of spiritual life, entertainment games that can be operated on terminals have emerged, such as multiplayer online action games, role-playing games, tactical competitive games or shooting games developed based on client or server architecture. Among them, pixel detection is a key technology in game development. It is used to determine the pixel-level collision of game elements (such as virtual characters, virtual items, and virtual scenes, etc.), and specifically can determine whether a certain game element is touched by a mouse or finger. In the prior art, by using pixel detection, game developers can more accurately produce the corresponding behaviors of game elements, thereby improving the realism of the game and the game experience of players.
目前,游戏引擎通常可以用于对游戏界面进行渲染以及进行像素检测等操作。但是,在某些特定环境下,由于存在对游戏引擎中读取像素接口进行限制,导致游戏引擎无法正常进行像素检测,从而无法正常监听碰撞检测事件,因此现有技术下,会通过回退到使用包围盒的测录方式进行碰撞检测。然而,采用包围盒进行碰撞检测的方式会存在鼠标或手指进行接触时误差会增大的情况,从而影响碰撞检测的精准性,影响玩家进行游戏时游戏交互的准确性,导致玩家的游戏体验较差。At present, game engines can usually be used to render game interfaces and perform pixel detection and other operations. However, in certain specific environments, due to restrictions on the pixel reading interface in the game engine, the game engine cannot perform pixel detection normally, and thus cannot monitor collision detection events normally. Therefore, under the existing technology, collision detection is performed by falling back to the measurement and recording method using bounding boxes. However, the method of using bounding boxes for collision detection will increase the error when the mouse or finger makes contact, thereby affecting the accuracy of collision detection and the accuracy of game interaction when the player is playing the game, resulting in a poor gaming experience for the player.
发明内容Summary of the invention
本申请实施例提供一种碰撞检测方法、装置、电子设备和存储介质,可以使游戏引擎在特定应用平台运行游戏时可以正常进行像素碰撞检测,提高了碰撞检测的精准性,提高了玩家在特定应用平台进行游戏时游戏交互的准确性,提升了玩家的游戏体验。The embodiments of the present application provide a collision detection method, device, electronic device and storage medium, which can enable a game engine to perform pixel collision detection normally when running a game on a specific application platform, thereby improving the accuracy of collision detection, improving the accuracy of game interaction when players play games on a specific application platform, and enhancing the player's gaming experience.
第一方面,本申请实施例提供一种碰撞检测方法,所述方法包括:In a first aspect, an embodiment of the present application provides a collision detection method, the method comprising:
启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;Starting a game engine, creating a first rendering function interface and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering;
通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;Rendering the application interface of the target application through the first rendering function interface to display the application interface;
响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;In response to a trigger operation on the application interface, obtaining an operation position of the trigger operation;
将所述操作位置命中的所述应用界面上的像素点作为目标像素点;Taking the pixel point on the application interface hit by the operation position as the target pixel point;
基于所述目标像素点确定待检测图像对象;Determine the image object to be detected based on the target pixel point;
调用所述第二渲染功能接口绘制所述待检测图像对象;Calling the second rendering function interface to draw the image object to be detected;
调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;Calling the second rendering function interface to obtain a target color parameter of the target pixel point, and determining whether the target color parameter satisfies a preset collision condition;
若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。If the target color parameter satisfies the preset collision condition, it is determined that a pixel collision occurs between the trigger operation and the image object to be detected.
第二方面,本申请实施例提供一种碰撞检测装置,包括:In a second aspect, an embodiment of the present application provides a collision detection device, comprising:
创建单元,用于启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;A creation unit, used to start a game engine, create a first rendering function interface, and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering;
第一调用单元,用于通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;A first calling unit, configured to render an application interface of a target application through the first rendering function interface to display the application interface;
响应单元,用于响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;A response unit, configured to obtain an operation position of the trigger operation in response to the trigger operation on the application interface;
处理单元,用于将所述操作位置命中的所述应用界面上的像素点作为目标像素点;A processing unit, configured to take the pixel point on the application interface hit by the operation position as a target pixel point;
第一确定单元,用于基于所述目标像素点确定待检测图像对象;A first determining unit, configured to determine an image object to be detected based on the target pixel point;
第二调用单元,用于调用所述第二渲染功能接口绘制所述待检测图像对象The second calling unit is used to call the second rendering function interface to draw the image object to be detected
第三调用单元,还调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;The third calling unit further calls the second rendering function interface to obtain a target color parameter of the target pixel point, and determines whether the target color parameter satisfies a preset collision condition;
第二确定单元,用于若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。The second determination unit is configured to determine that a pixel collision occurs between the trigger operation and the image object to be detected if the target color parameter satisfies the preset collision condition.
第三方面,本申请实施例还提供一种电子设备,包括存储器存储有多条指令;处理器从存储器中加载指令,以执行本申请实施例所提供的任一种碰撞检测方法的步骤。In a third aspect, an embodiment of the present application further provides an electronic device, including a memory storing a plurality of instructions; a processor loads the instructions from the memory to execute the steps of any collision detection method provided in the embodiment of the present application.
第四方面,本申请实施例还提供一种计算机可读存储介质,计算机可读存储介质存储有多条指令,指令适于处理器进行加载,以执行本申请实施例所提供的任一种碰撞检测方法的步骤。In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a plurality of instructions suitable for loading by a processor to execute the steps of any collision detection method provided in the embodiment of the present application.
第五方面,本申请实施例还提供一种计算机程序产品,包括计算机程序或指令,计算机程序或指令被处理器执行时实现本申请实施例所提供的任一种碰撞检测方法中的步骤。In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of any collision detection method provided in the embodiment of the present application.
采用本申请实施例的方案,可以通过创建两个渲染功能接口,一个渲染功能接口用于进行界面渲染等操作,另一个渲染功能接口用于进行像素碰撞检测的操作,从而可以使游戏引擎在特定应用平台运行游戏时可以正常进行像素碰撞检测,提高了碰撞检测的精准性,提高了玩家在特定应用平台进行游戏时游戏交互的准确性,提升了玩家的游戏体验。By adopting the solution of the embodiment of the present application, two rendering function interfaces can be created, one rendering function interface is used to perform operations such as interface rendering, and the other rendering function interface is used to perform pixel collision detection operations, so that the game engine can perform pixel collision detection normally when running the game on a specific application platform, thereby improving the accuracy of collision detection, improving the accuracy of game interaction when players play games on a specific application platform, and enhancing the player's gaming experience.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
图1是本申请实施例提供的碰撞检测系统的场景示意图;FIG1 is a schematic diagram of a scene of a collision detection system provided in an embodiment of the present application;
图2是本申请实施例提供的碰撞检测方法的一种实施例流程示意图;FIG2 is a schematic diagram of a flow chart of an embodiment of a collision detection method provided in an embodiment of the present application;
图3是本申请实施例中提供的碰撞检测装置的结构示意图;FIG3 is a schematic diagram of the structure of a collision detection device provided in an embodiment of the present application;
图4是本申请实施例中提供的电子设备的结构示意图。FIG. 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
具体实施方式DETAILED DESCRIPTION
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。同时,在本申请实施例的描述中,术语“第一”、“第二”等仅用于区分描述,而不能理解为指示或暗示相对重要性。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个特征。在本申请实施例的描述中,“多个”的含义是两个或两个以上,除非另有明确具体的限定。The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
本申请实施例提供一种碰撞检测方法、装置、电子设备和计算机可读存储介质。具体地,本实施例将从碰撞检测装置的角度进行描述,该碰撞检测装置具体可以集成在电子设备中,即本申请实施例碰撞检测方法可以由电子设备执行,可选的,该电子设备可以包括:终端设备。终端设备可以为手机、平板电脑、智能蓝牙设备、笔记本电脑、游戏机、或者个人电脑(Personal Computer,PC)等设备。The embodiments of the present application provide a collision detection method, device, electronic device, and computer-readable storage medium. Specifically, the present embodiment will be described from the perspective of a collision detection device, which can be integrated into an electronic device, that is, the collision detection method of the embodiment of the present application can be performed by an electronic device, and optionally, the electronic device can include: a terminal device. The terminal device can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a game console, or a personal computer (PC) and other devices.
本申请实施例提供的碰撞检测方法,可以应用于如碰撞检测系统中。其中,该碰撞检测系统可以包括玩家终端设备和服务器,终端可以是既包括接收和发射硬件的设备,即具有能够在双向通信链路上,执行双向通信的接收和发射硬件的设备。玩家终端设备与服务器可以通过网络进行双向通信。The collision detection method provided in the embodiment of the present application can be applied to, for example, a collision detection system. The collision detection system may include a player terminal device and a server, and the terminal may be a device including both receiving and transmitting hardware, that is, a device having receiving and transmitting hardware capable of performing two-way communication on a two-way communication link. The player terminal device and the server may perform two-way communication via a network.
可选的,该服务器可以是独立的服务器,也可以是服务器组成的服务器网络或服务器集群,其包括但不限于计算机、网络主机、单个网络服务器、多个网络服务器集或多个服务器构成的云服务器。其中,云服务器由基于云计算(Cloud Computing)的大量计算机或网络服务器构成。Optionally, the server may be an independent server, or a server network or server cluster composed of servers, including but not limited to a computer, a network host, a single network server, a plurality of network server sets or a cloud server composed of multiple servers. The cloud server is composed of a large number of computers or network servers based on cloud computing.
在本公开其中一种实施例中的碰撞检测方法可以运行于本地终端设备或者是服务器。当碰撞检测方法运行于服务器时,该方法则可以基于云交互系统来实现与执行,其中,云交互系统包括服务器和客户端设备。The collision detection method in one embodiment of the present disclosure may be run on a local terminal device or a server. When the collision detection method is run on a server, the method may be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
例如,当该碰撞检测方法运行于终端时,终端设备存储有游戏应用程序并用于呈现游戏画面中的虚拟场景。终端设备用于通过图形用户界面与用户进行交互,例如通过终端设备下载安装游戏应用程序并运行。该终端设备将图形用户界面提供给用户的方式可以包括多种,例如,可以渲染显示在终端设备的显示屏上,或者,通过全息投影呈现图形用户界面。例如,终端设备可以包括触控显示屏和处理器,该触控显示屏用于呈现图形用户界面以及接收用户作用于图形用户界面产生的操作指令,该图形用户界面包括游戏画面,该处理器用于运行该游戏、生成图形用户界面、响应操作指令以及控制图形用户界面在触控显示屏上的显示。For example, when the collision detection method is run on a terminal, the terminal device stores a game application and is used to present a virtual scene in the game screen. The terminal device is used to interact with the user through a graphical user interface, for example, the game application is downloaded and installed through the terminal device and run. The terminal device may provide the graphical user interface to the user in a variety of ways, for example, it may be rendered and displayed on the display screen of the terminal device, or the graphical user interface may be presented through holographic projection. For example, the terminal device may include a touch display screen and a processor, the touch display screen is used to present the graphical user interface and receive the operation instructions generated by the user acting on the graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, respond to the operation instructions, and control the display of the graphical user interface on the touch display screen.
例如,当该碰撞检测方法运行于服务器时,可以为云游戏。云游戏是指以云计算为基础的游戏方式。在云游戏的运行模式下,游戏应用程序的运行主体和游戏画面呈现主体是分离的,碰撞检测方法的储存与运行是在云游戏服务器上完成的。而游戏画面呈现是在云游戏的客户端完成的,云游戏客户端主要用于游戏数据的接收、发送以及游戏画面的呈现,例如,云游戏客户端可以是靠近用户侧的具有数据传输功能的显示设备,如,移动终端、电视机、计算机、掌上电脑、个人数字助理等,但是进行游戏数据处理的终端设备为云端的云游戏服务器。在进行游戏时,用户操作云游戏客户端向云游戏服务器发送操作指令,云游戏服务器根据操作指令运行游戏,将游戏画面等数据进行编码压缩,通过网络返回云游戏客户端,最后,通过云游戏客户端进行解码并输出游戏画面。For example, when the collision detection method is run on a server, it can be a cloud game. Cloud gaming refers to a gaming method based on cloud computing. In the operation mode of cloud gaming, the operating body of the game application and the game screen presentation body are separated, and the storage and operation of the collision detection method are completed on the cloud gaming server. The game screen presentation is completed on the client of the cloud gaming. The cloud gaming client is mainly used for receiving and sending game data and presenting the game screen. For example, the cloud gaming client can be a display device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a PDA, a personal digital assistant, etc., but the terminal device for processing game data is a cloud gaming server in the cloud. When playing the game, the user operates the cloud gaming client to send an operation instruction to the cloud gaming server. The cloud gaming server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the cloud gaming client through the network. Finally, the cloud gaming client decodes and outputs the game screen.
请参阅图1,图1为本申请实施例提供的一种碰撞检测系统的场景示意图。该系统可以包括至少一个终端,至少一个服务器,至少一个数据库,以及网络。用户持有的终端可以通过网络连接到不同游戏的服务器。终端是具有计算硬件的任何设备,该计算硬件能够支持和执行与游戏对应的软件产品。另外,当系统包括多个终端、多个服务器、多个网络时,不同的终端可以通过不同的网络、通过不同的服务器相互连接。网络可以是无线网络或者有线网络,比如无线网络为无线局域网(WLAN)、局域网(LAN)、蜂窝网络、2G网络、3G网络、4G网络、5G网络等。另外,不同的终端之间也可以使用自身的蓝牙网络或者热点网络连接到其他终端或者连接到服务器等。例如,多个用户可以通过不同的终端在线从而通过适当网络连接并且相互同步,以支持多玩家游戏。另外,该系统可以包括多个数据库,多个数据库耦合到不同的服务器,并且可以将与游戏环境有关的信息在不同用户在线进行多玩家游戏时连续地存储于数据库中。Please refer to Figure 1, which is a scene diagram of a collision detection system provided by an embodiment of the present application. The system may include at least one terminal, at least one server, at least one database, and a network. The terminal held by the user can be connected to the servers of different games through the network. The terminal is any device with computing hardware that can support and execute software products corresponding to the game. In addition, when the system includes multiple terminals, multiple servers, and multiple networks, different terminals can be connected to each other through different networks and different servers. The network can be a wireless network or a wired network, such as a wireless network such as a wireless local area network (WLAN), a local area network (LAN), a cellular network, a 2G network, a 3G network, a 4G network, a 5G network, etc. In addition, different terminals can also use their own Bluetooth network or hotspot network to connect to other terminals or to servers, etc. For example, multiple users can be online through different terminals and connected and synchronized with each other through appropriate networks to support multi-player games. In addition, the system may include multiple databases, multiple databases are coupled to different servers, and information related to the game environment can be continuously stored in the database when different users are online for multi-player games.
本申请实施例提供了一种碰撞检测方法,该方法可以由终端或服务器执行。本申请实施例以碰撞检测方法由终端执行为例来进行说明。其中,该终端可以包括触控显示屏和处理器(当然,终端也可以采用鼠标、键盘等外设作为输入设备,此处仅以触控显示屏为例进行说明),该触控显示屏用于呈现图形用户界面以及接收用户作用于图形用户界面产生的操作指令。用户通过触控显示屏对图形用户界面进行操作时,该图形用户界面可以通过响应于接收到的操作指令控制终端本地的内容,也可以通过响应于接收到的操作指令控制对端服务器的内容。例如,用户作用于图形用户界面产生的操作指令包括用于启动游戏应用程序的指令,处理器被配置为在接收到用户提供的启动游戏应用程序的指令之后启动游戏应用程序。此外,处理器被配置为在触控显示屏上渲染和绘制与游戏相关联的图形用户界面。触控显示屏是能够感测屏幕上的多个点同时执行的触摸或者滑动操作的多触敏屏幕。用户在使用手指在图形用户界面上执行触控操作,图形用户界面在检测到触控操作时,控制游戏的图形用户界面中的不同虚拟对象执行与触控操作对应的动作。The embodiment of the present application provides a collision detection method, which can be executed by a terminal or a server. The embodiment of the present application takes the collision detection method executed by a terminal as an example for explanation. Among them, the terminal may include a touch display screen and a processor (of course, the terminal may also use peripherals such as a mouse and a keyboard as input devices, and only the touch display screen is used as an example for explanation here), and the touch display screen is used to present a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. When the user operates the graphical user interface through the touch display screen, the graphical user interface can control the local content of the terminal by responding to the received operation instructions, and can also control the content of the opposite server by responding to the received operation instructions. For example, the operation instructions generated by the user acting on the graphical user interface include instructions for starting a game application, and the processor is configured to start the game application after receiving the instructions for starting the game application provided by the user. In addition, the processor is configured to render and draw a graphical user interface associated with the game on the touch display screen. The touch display screen is a multi-touch sensitive screen that can sense touch or sliding operations performed simultaneously at multiple points on the screen. The user uses a finger to perform a touch operation on the graphical user interface, and when the graphical user interface detects the touch operation, the different virtual objects in the graphical user interface of the game are controlled to perform actions corresponding to the touch operation.
需要说明的是,图1所示的碰撞检测系统的场景示意图仅仅是一个示例,本申请实施例描述的碰撞检测系统以及场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。It should be noted that the scenario diagram of the collision detection system shown in Figure 1 is merely an example. The collision detection system and scenario described in the embodiment of the present application are intended to more clearly illustrate the technical solution of the embodiment of the present application, and do not constitute a limitation on the technical solution provided in the embodiment of the present application. Ordinary technicians in this field can know that with the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems.
本申请实施例提供一种碰撞检测方法,该方法可以由终端或服务器执行,本申请实施例以碰撞检测方法由终端执行为例来进行说明,可以通过终端设备提供一图形用户界面(即应用界面),图形用户界面包括至少部分虚拟场景、位于所述虚拟场景中由所述终端设备控制的受控虚拟对象(即界面元素)。以下对图形用户界面、虚拟场景、以及虚拟对象进行说明。The embodiment of the present application provides a collision detection method, which can be executed by a terminal or a server. The embodiment of the present application takes the collision detection method executed by a terminal as an example for explanation, and a graphical user interface (i.e., an application interface) can be provided by a terminal device, and the graphical user interface includes at least part of a virtual scene, and a controlled virtual object (i.e., an interface element) located in the virtual scene and controlled by the terminal device. The graphical user interface, virtual scene, and virtual object are explained below.
游戏场景(或称为虚拟场景)是应用程序在终端或服务器上运行时显示(或提供)的虚拟场景。可选地,该虚拟场景是对真实世界的仿真环境,或者是半仿真半虚构的虚拟环境,或者是纯虚构的虚拟环境。虚拟场景是二维虚拟场景和三维虚拟场景中的任意一种,虚拟环境可以为天空、陆地、海洋等,其中,该陆地包括沙漠、城市等环境元素。其中,虚拟场景为用户控制等虚拟对象完整游戏逻辑的场景,例如,对于沙盒类3D射击游戏中,虚拟场景为用于供玩家控制虚拟对象进行对战的3D游戏世界,实例性的虚拟场景可以包括:山川、平地、河流、湖泊、海洋、沙漠、天空、植物、建筑、车辆中的至少一种元素;例如,对于2D卡牌类游戏中,虚拟场景为供展示释放卡牌或是展示卡牌对应的虚拟对象的场景,实例性的虚拟场景可以包括:擂台场、决战场、或是其他可以显示卡牌对战状态的“场”元素或是其他元素;对于2D或是3D的多人在线战术竞技游戏,虚拟场景为供虚拟对象进行对战的2D或3D地形场景,实例性的虚拟场景可以包括:峡谷风格的山脉、线路、河流、教室、桌椅、讲台等元素。The game scene (or virtual scene) is a virtual scene displayed (or provided) when the application is running on a terminal or server. Optionally, the virtual scene is a simulation environment of the real world, or a semi-simulation and semi-fictitious virtual environment, or a purely fictitious virtual environment. The virtual scene is any one of a two-dimensional virtual scene and a three-dimensional virtual scene, and the virtual environment can be the sky, land, ocean, etc., wherein the land includes environmental elements such as deserts and cities. Among them, the virtual scene is a scene with complete game logic of virtual objects such as user control. For example, for sandbox 3D shooting games, the virtual scene is a 3D game world for players to control virtual objects to fight. Example virtual scenes may include: at least one element of mountains, plains, rivers, lakes, oceans, deserts, skies, plants, buildings, and vehicles; for example, for 2D card games, the virtual scene is a scene for displaying released cards or displaying virtual objects corresponding to cards. Example virtual scenes may include: an arena, a decisive battlefield, or other "field" elements or other elements that can display the status of card battles; for 2D or 3D multiplayer online tactical competitive games, the virtual scene is a 2D or 3D terrain scene for virtual objects to fight. Example virtual scenes may include: canyon-style mountains, lines, rivers, classrooms, tables and chairs, podiums and other elements.
图形用户界面是通过在移动终端或其它终端的处理器上执行软件应用并在显示器上渲染得到图形用户界面,可以是终端设备的显示屏界面。图形用户界面可以呈现游戏场景的全部,也可以只呈现游戏场景的局部。游戏场景中包括多个静态虚拟对象,具体包括地面、山体、石体、植被、建筑等。当游戏场景比较大时,在游戏的过程中终端设备的图形用户界面上只显示游戏场景的局部内容。可选地,游戏场景中包含游戏角色,游戏角色可以是玩家操控的游戏角色,也可以NPC(non-player character的缩写,是游戏中一种角色类型,意思是非玩家角色),本示例性实施例不作限制。图形用户界面中可以包括供玩家进行交互的UI界面和游戏画面。在可选的实施方式中,该UI界面中可以包括游戏控件(如,技能控件、移动控件、功能控件等)、指示标识(如,方向指示标识、角色指示标识等)、信息展示区(如,击杀人数、比赛时间等),或是游戏设置控件(如,系统设置、商店、金币等)。在可选的实施方式中,游戏画面为终端设备显示虚拟场景所对应的显示画面,游戏画面中可以包括在虚拟场景中进行执行游戏逻辑的游戏角色、NPC角色、AI角色等虚拟对象。The graphical user interface is obtained by executing a software application on a processor of a mobile terminal or other terminal and rendering it on a display, and can be a display screen interface of a terminal device. The graphical user interface can present the entire game scene, or only a part of the game scene. The game scene includes multiple static virtual objects, specifically including ground, mountains, rocks, vegetation, buildings, etc. When the game scene is relatively large, only the local content of the game scene is displayed on the graphical user interface of the terminal device during the game. Optionally, the game scene contains game characters, which can be game characters controlled by players, or NPCs (abbreviation of non-player characters, which is a type of character in the game, meaning non-player characters), which is not limited in this exemplary embodiment. The graphical user interface can include a UI interface and a game screen for players to interact. In an optional embodiment, the UI interface can include game controls (such as skill controls, mobile controls, function controls, etc.), indicator signs (such as direction indicator signs, role indicator signs, etc.), information display areas (such as the number of kills, game time, etc.), or game setting controls (such as system settings, stores, gold coins, etc.). In an optional implementation, the game screen is a display screen corresponding to a virtual scene displayed by a terminal device, and the game screen may include virtual objects such as game characters, NPC characters, AI characters, etc. that execute game logic in the virtual scene.
游戏对象(或称为虚拟对象、游戏角色)是指在虚拟场景中可被控制的动态对象。可选地,该动态对象可以是虚拟人物、虚拟动物、动漫人物等。该虚拟对象是玩家通过输入设备进行控制的角色,或者是通过训练设置在虚拟环境对战中的人工智能(ArtificialIntelligence,AI),或者是设置在虚拟场景对战中的非玩家角色(Non-Player Character,NPC)。可选地,该虚拟对象是在虚拟场景中进行竞技的虚拟人物。可选地,该虚拟场景对战中的虚拟对象的数量是预设设置的,或者是根据加入对战的客户端的数量动态确定的,本申请实施例对此不作限定。在一种可能实现方式中,用户能够控制虚拟对象在该虚拟场景中进行移动,例如,控制虚拟对象跑动、跳动、爬行等,也能够控制虚拟对象使用应用程序所提供的技能、虚拟道具等与其他虚拟对象进行战斗。(游戏)道具是指虚拟对象在虚拟环境中能够使用的道具,包括但不限于枪械、冷兵器、手雷、护盾、跳板、傀儡等能够被虚拟对象使用,以提速自身属性、辅助作战或是对其他虚拟对象发起伤害的虚拟物品,虚拟道具还可以是子弹等补给道具,还可以为扩充弹夹、瞄准倍镜、消焰器、枪托等配件装配在指定虚拟武器上。虚拟摄像机是游戏场景画面所必需的组件,用于游戏场景画面的呈现,一个游戏场景至少对应一个虚拟摄像机,根据实际需要,可以有两个或两个以上,作为游戏渲染的窗口,为玩家捕捉和呈现游戏世界的画面内容,通过设置虚拟摄像机的参数可调整玩家观看游戏世界的视角,如第一人称视角、第三人称视角。A game object (or virtual object, game character) refers to a dynamic object that can be controlled in a virtual scene. Optionally, the dynamic object can be a virtual character, a virtual animal, a cartoon character, etc. The virtual object is a character controlled by a player through an input device, or an artificial intelligence (AI) set in a virtual environment battle through training, or a non-player character (NPC) set in a virtual scene battle. Optionally, the virtual object is a virtual character competing in a virtual scene. Optionally, the number of virtual objects in the virtual scene battle is preset, or is dynamically determined according to the number of clients joining the battle, and the embodiment of the present application does not limit this. In a possible implementation, the user can control the virtual object to move in the virtual scene, for example, control the virtual object to run, jump, crawl, etc., and can also control the virtual object to use the skills, virtual props, etc. provided by the application to fight with other virtual objects. (Game) props refer to props that can be used by virtual objects in a virtual environment, including but not limited to firearms, cold weapons, grenades, shields, springboards, puppets, etc., which can be used by virtual objects to speed up their own attributes, assist in combat, or launch damage to other virtual objects. Virtual props can also be supply props such as bullets, and can also be equipped on designated virtual weapons for accessories such as extended magazines, aiming scopes, flash suppressors, and stocks. The virtual camera is a necessary component for the game scene screen, which is used to present the game scene screen. A game scene corresponds to at least one virtual camera. According to actual needs, there can be two or more virtual cameras, which serve as the game rendering window to capture and present the game world's screen content to the player. By setting the parameters of the virtual camera, the player's perspective of viewing the game world can be adjusted, such as the first-person perspective and the third-person perspective.
以下结合附图分别进行详细说明,本实施例中以执行主体是终端设备为例。需说明的是,以下实施例的描述顺序不作为对实施例优选顺序的限定。虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于附图所示的顺序执行所示出或描述的步骤。The following is a detailed description in conjunction with the accompanying drawings. In this embodiment, the execution subject is a terminal device as an example. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
请参阅图2,图2为本申请实施例提供的一种碰撞检测方法的流程示意图,该碰撞检测方法的具体流程可以如下步骤101至步骤108:Please refer to FIG. 2 , which is a schematic diagram of a flow chart of a collision detection method provided in an embodiment of the present application. The specific flow of the collision detection method may be as follows: Steps 101 to 108:
步骤101、启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染。Step 101: Start a game engine, create a first rendering function interface, and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering.
其中,游戏引擎可以为Egret引擎,Egret引擎是一款由Egret Technologies开发的基于HTML5技术的二维(2D)游戏引擎。它使用TypeScript作为开发语言,提供了一套完整的2D游戏解决方案,包括显示对象、事件系统、动画、网络、声音、资源加载等基础组件,还可以包括UI系统、EUI编辑器、粒子系统、龙骨动画系统等扩展组件。The game engine may be the Egret engine, which is a two-dimensional (2D) game engine based on HTML5 technology developed by Egret Technologies. It uses TypeScript as a development language and provides a complete set of 2D game solutions, including basic components such as display objects, event systems, animations, networks, sounds, and resource loading, and may also include extended components such as UI systems, EUI editors, particle systems, and keel animation systems.
本申请实施例中提到的渲染功能接口为WebGL上下文,第一渲染功能接口为WebGL上下文-主,第二渲染功能接口为WebGL上下文-副,具体的,WebGL上下文-主维持其原本默认的功能不变,依然作为游戏的渲染目标,即用于进行游戏画面的渲染显示;另外一WebGL上下文-副,不被渲染出来,仅仅用于进行像素碰撞检测。The rendering function interface mentioned in the embodiment of the present application is a WebGL context, the first rendering function interface is a WebGL context-primary, and the second rendering function interface is a WebGL context-secondary. Specifically, the WebGL context-primary maintains its original default function unchanged and still serves as the rendering target of the game, that is, it is used for rendering and displaying the game screen; the other WebGL context-secondary is not rendered and is only used for pixel collision detection.
其中,WebGL上下文是指WebGL(Web Graphics Library)在浏览器中创建和操作3D图形的环境,WebGL是一种基于OpenGL ES2.0的跨平台的图形API,它使用JavaScript编程语言,允许开发者在Web浏览器中创建交互式3D图形和动画。具体的,WebGL上下文是通过在HTML文档中的canvas元素上调用getContext("webgl")函数来创建的。一旦获取到WebGL上下文,开发者就可以使用WebGL的各种函数来定义和绘制3D图形,控制着色器,设置纹理等。WebGL上下文提供了一个与硬件加速图形渲染器进行交互的接口,使得在浏览器中绘制复杂的3D图形成为可能。也就是说,WebGL上下文提供了底层的图形编程接口,开发者可以使用JavaScript编写程序来操作图形渲染管道的各个阶段,从而实现自定义的3D图形效果。它提供了强大的图形处理功能,可以利用显卡的并行计算能力来加快渲染速度,同时支持硬件加速的光照、纹理映射、投影等高级图形特效。Among them, WebGL context refers to the environment in which WebGL (Web Graphics Library) creates and operates 3D graphics in the browser. WebGL is a cross-platform graphics API based on OpenGL ES2.0. It uses the JavaScript programming language and allows developers to create interactive 3D graphics and animations in a web browser. Specifically, the WebGL context is created by calling the getContext("webgl") function on the canvas element in an HTML document. Once the WebGL context is obtained, developers can use various WebGL functions to define and draw 3D graphics, control shaders, set textures, etc. The WebGL context provides an interface for interacting with a hardware-accelerated graphics renderer, making it possible to draw complex 3D graphics in a browser. In other words, the WebGL context provides an underlying graphics programming interface, and developers can use JavaScript to write programs to operate various stages of the graphics rendering pipeline to achieve customized 3D graphics effects. It provides powerful graphics processing capabilities, can use the parallel computing capabilities of graphics cards to speed up rendering, and supports advanced graphics effects such as hardware-accelerated lighting, texture mapping, and projection.
在一实施例中,所述方法还包括:In one embodiment, the method further comprises:
为所述第二渲染功能接口对应的图像对象设置指定属性,其中,所述指定属性用于指示所述图像对象不会被渲染、以使所述图像对象用于进行像素碰撞检测。A specified attribute is set for the image object corresponding to the second rendering function interface, wherein the specified attribute is used to indicate that the image object will not be rendered so that the image object is used for pixel collision detection.
在本申请实施例中,可以为图像对象(Image对象)设置指定属性(bOnlyPixelHitTest:boolean),该指定属性用于控制Image实例对象的作用范围。当image对象的bOnlyPixelHitTest的属性值为true时,则要设置不进行渲染,也即表明该image对象不会被渲染到WebGL上下文-主上,也就不会被显示出来。只有当需要进行像素碰撞检测时,才会将该image对象绘制到WebGL上下文-副上,进行像素碰撞检测。In an embodiment of the present application, a specified attribute (bOnlyPixelHitTest: boolean) can be set for an image object (Image object), and the specified attribute is used to control the scope of the Image instance object. When the attribute value of bOnlyPixelHitTest of the image object is true, it is set not to render, which means that the image object will not be rendered to the WebGL context-primary, and will not be displayed. Only when pixel collision detection is required, the image object will be drawn to the WebGL context-secondary for pixel collision detection.
具体的,bOnlyPixelHitTest是Egret引擎中egret.Bitmap类的一个属性,用于指定是否只进行像素级的碰撞检测。在Egret引擎中,碰撞检测是用于判断两个物体是否发生碰撞的过程。通常,碰撞检测会使用两个物体的边界框(bounding box)进行比较来确定它们是否相交,但有时候可能需要更精确的碰撞检测,即只在物体的像素级别上进行比较。当将bOnlyPixelHitTest属性设置为true时,egret.Bitmap对象在进行碰撞检测时只会考虑像素级别的比较,也即会对两个物体的像素进行逐一比较来确定碰撞是否发生,而不仅仅是比较它们的边界框。Specifically, bOnlyPixelHitTest is a property of the egret.Bitmap class in the Egret engine, which is used to specify whether only pixel-level collision detection is performed. In the Egret engine, collision detection is the process used to determine whether two objects collide. Usually, collision detection uses the bounding boxes of two objects to compare to determine whether they intersect, but sometimes more precise collision detection may be required, that is, only comparing at the pixel level of the objects. When the bOnlyPixelHitTest property is set to true, the egret.Bitmap object will only consider pixel-level comparisons when performing collision detection, that is, it will compare the pixels of the two objects one by one to determine whether a collision occurs, rather than just comparing their bounding boxes.
其中,Image对象是在JavaScript中代表图像的内置对象,它可以用来加载和操作图像,通常用于在网页中显示图像或进行图像处理,通过创建Image对象,可以加载图像文件并将其显示在网页中。除了加载和显示图像,Image对象还提供了一些其他有用的属性和事件,一些常用的属性包括width(图像的宽度)、height(图像的高度)、naturalWidth(图像的原始宽度,只读)、naturalHeight(图像的原始高度,只读)、complete(指示图片是否加载完成)等。此外,Image对象还有一些事件,如onload(图像加载完成时触发)、onerror(图像加载出错时触发)等,可以用于检测图像的加载状态。综上,Image对象是用于加载和操作图像的内置对象,它可以加载图像文件并将其显示在网页上。同时,还提供了一些有用的属性和事件,以便对图像进行处理和操作。Among them, the Image object is a built-in object that represents an image in JavaScript. It can be used to load and manipulate images. It is usually used to display images or perform image processing on web pages. By creating an Image object, you can load image files and display them on web pages. In addition to loading and displaying images, the Image object also provides some other useful properties and events. Some commonly used properties include width (width of the image), height (height of the image), naturalWidth (original width of the image, read-only), naturalHeight (original height of the image, read-only), complete (indicates whether the image has been loaded), etc. In addition, the Image object also has some events, such as onload (triggered when the image is loaded), onerror (triggered when an error occurs in the image loading), etc., which can be used to detect the loading status of the image. In summary, the Image object is a built-in object for loading and manipulating images. It can load image files and display them on web pages. At the same time, it also provides some useful properties and events to process and manipulate images.
在另一实施例中,所述方法还包括:In another embodiment, the method further comprises:
创建指定全局对象,所述指定全局对象用于使所述第二渲染功能接口可绘制所述图像对象。A specified global object is created, where the specified global object is used to enable the second rendering function interface to draw the image object.
其中,全局对象可以为customHitTestBuffer2,该全局对象可以为第二渲染功能接口(即WebGL上下文-副)的环境对象,在Web开发中,环境对象通常用于配置应用程序在不同环境下可执行的行为,环境对象可以包含为WebGL上下文-副设置的环境信息和资源配置,也即WebGL的环境对象是用于配置和管理图形渲染的重要接口,通过环境对象可以控制渲染状态以及分配着色器资源。因此,当检测到当前环境下不支持WebGL上下文-主进行像素检测时,可以为WebGL上下文-副创建全局对象customHitTestBuffer2,通过该全局对象指示WebGL上下文-主无法进行像素碰撞检测,此时需要通过WebGL上下文-副进行像素碰撞检测;并且,着色器还可以根据该全局对象为WebGL上下文-副分配对应的着色器资源,以使WebGL上下文-副使用对应的着色器资源绘制图像对象,且不对该图像对象进行渲染操作,从而使WebGL上下文-副基于该图像对象进行像素碰撞检测。Among them, the global object can be customHitTestBuffer2, which can be the environment object of the second rendering function interface (i.e., WebGL context-sub). In Web development, the environment object is usually used to configure the behavior that the application can execute in different environments. The environment object can contain the environment information and resource configuration set for the WebGL context-sub, that is, the WebGL environment object is an important interface for configuring and managing graphics rendering. The rendering state and shader resources can be controlled through the environment object. Therefore, when it is detected that the WebGL context-primary does not support pixel detection in the current environment, a global object customHitTestBuffer2 can be created for the WebGL context-sub, and the global object is used to indicate that the WebGL context-primary cannot perform pixel collision detection. At this time, pixel collision detection needs to be performed through the WebGL context-sub; and the shader can also allocate corresponding shader resources to the WebGL context-sub according to the global object, so that the WebGL context-sub uses the corresponding shader resources to draw the image object, and does not perform rendering operations on the image object, so that the WebGL context-sub performs pixel collision detection based on the image object.
在本申请实施例中,由于特定应用平台上的平台限制,当该平台配置了openDataContext后,用于进行游戏渲染的WebGL上下文是无法获取游戏图片的像素值的,也就是Egret引擎在尝试调用像素检测的函数时是不成功的,无法进行像素碰撞检测,也即当前环境下不支持WebGL上下文-主进行像素检测。因此,则需要创建一个全局对象customHitTestBuffer2(也即环境对象),通过该全局对象customHitTestBuffer2为WebGL上下文-副配置可用于进行像素碰撞检测的着色器资源,从而使得WebGL上下文-副可进行像素碰撞检测。如果当前环境支持WebGL上下文-主进行像素检测,则不会创建customHitTestBuffer2。具体的,当检测到游戏运行在应用程序的小游戏平台或小程序平台时,也即可以确定当前环境下不支持WebGL上下文-主进行像素检测,可以在Egret引擎中声明一个全局对象(customHitTestBuffer2),通过创建一个全局对象,从而指示当前运行环境无法供WebGL上下文-主进行像素碰撞检测,需要通过WebGL上下文-副进行像素碰撞检测。In an embodiment of the present application, due to platform limitations on a specific application platform, when the platform is configured with openDataContext, the WebGL context used for game rendering cannot obtain the pixel value of the game image, that is, the Egret engine is unsuccessful when trying to call the pixel detection function, and cannot perform pixel collision detection, that is, the WebGL context-main pixel detection is not supported in the current environment. Therefore, it is necessary to create a global object customHitTestBuffer2 (that is, the environment object), and through the global object customHitTestBuffer2, the WebGL context-sub is configured with shader resources that can be used for pixel collision detection, so that the WebGL context-sub can perform pixel collision detection. If the current environment supports the WebGL context-main pixel detection, customHitTestBuffer2 will not be created. Specifically, when it is detected that the game is running on the application's mini-game platform or mini-program platform, it can be determined that the WebGL context-main pixel detection is not supported in the current environment. A global object (customHitTestBuffer2) can be declared in the Egret engine, and a global object is created to indicate that the current operating environment cannot be used for the WebGL context-main pixel collision detection, and the WebGL context-sub is required to perform pixel collision detection.
进一步的,步骤“所述调用所述第二渲染功能接口绘制所述待检测图像对象”,包括:Furthermore, the step of “calling the second rendering function interface to draw the image object to be detected” includes:
当检测到存在所述指定全局对象,且所述待检测图像对象的指定属性的属性值为预设属性值时,基于所述指定全局对象绘制所述待检测图像对象。When the existence of the designated global object is detected, and the attribute value of the designated attribute of the image object to be detected is a preset attribute value, the image object to be detected is drawn based on the designated global object.
例如,当检测到存在所述指定全局对象,也即存在指定全局对象customHitTestBuffer2时,且待检测图像对象的指定属性的属性值为预设属性值时,也即待检测图像对象的bOnlyPixelHitTest的属性值为true时,通过所述指定全局对象绘制所述待检测图像对象。For example, when the existence of the specified global object, that is, the existence of the specified global object customHitTestBuffer2, and the attribute value of the specified attribute of the image object to be detected is the preset attribute value, that is, the attribute value of bOnlyPixelHitTest of the image object to be detected is true, the image object to be detected is drawn through the specified global object.
具体的,步骤“所述启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口”,包括:Specifically, the step of “starting the game engine and creating a first rendering function interface and a second rendering function interface” includes:
启动游戏引擎,创建第一画布以及第二画布;Start the game engine and create the first canvas and the second canvas;
基于所述第一画布创建第一渲染功能接口,并基于所述第二画布创建第二渲染功能接口。A first rendering function interface is created based on the first canvas, and a second rendering function interface is created based on the second canvas.
由于特定应用平台(例如聊天软件)上小游戏平台的限制,当配置了openDataContext后,游戏渲染的WebGL上下文是无法获取游戏图片的像素值的,也就是Egret引擎在尝试调用像素检测的函数时,是不成功的。因此,在本申请实施例中,可以修改Egret引擎代码,让其由创建唯一WebGL上下文,改成支持创建两个WebGL上下文。具体可以创建两个画布(Canvas)来分别创建第一渲染功能接口和第二渲染功能接口。Due to the limitations of the mini-game platform on a specific application platform (such as chat software), when openDataContext is configured, the WebGL context rendered by the game cannot obtain the pixel value of the game image, that is, the Egret engine is unsuccessful when trying to call the pixel detection function. Therefore, in an embodiment of the present application, the Egret engine code can be modified to support the creation of two WebGL contexts instead of creating a unique WebGL context. Specifically, two canvases can be created to create a first rendering function interface and a second rendering function interface respectively.
其中,openDataContext是指小程序开放数据域(Open Data Context)的概念。例如在聊天软件的小程序中,openDataContext是一个独立的JavaScript执行环境,它可以用于在小游戏(小程序游戏)中提供跨页面的数据共享和交流。小游戏指的是小程序中的游戏性质的部分。openDataContext的目的是为了解决小程序游戏中不同页面之间共享数据和通信的需求。通常情况下,每个小程序页面都运行在自己的独立的JavaScript环境中,它们彼此之间的数据难以共享。但是,通过使用openDataContext,开发者可以在小游戏中创建一个共享的数据域,使得不同页面间可以共享数据并进行通信。在openDataContext中,开发者可以定义需要共享的数据,并通过postMessage方法发送消息给其他页面。其他页面可以通过监听onMessage方法接收openDataContext发送的消息,从而实现数据共享和交流。openDataContext提供了一个独立的数据共享和交流环境,使得小游戏中的不同页面能够跨页面进行数据共享和通信,从而更好地实现小游戏中的功能和体验。Among them, openDataContext refers to the concept of the open data domain (Open Data Context) of the mini program. For example, in the mini program of the chat software, openDataContext is an independent JavaScript execution environment, which can be used to provide cross-page data sharing and communication in the mini game (mini program game). Mini game refers to the game-like part of the mini program. The purpose of openDataContext is to solve the need for sharing data and communication between different pages in the mini program game. Usually, each mini program page runs in its own independent JavaScript environment, and it is difficult for them to share data with each other. However, by using openDataContext, developers can create a shared data domain in the mini game, so that different pages can share data and communicate. In openDataContext, developers can define the data that needs to be shared and send messages to other pages through the postMessage method. Other pages can receive messages sent by openDataContext by listening to the onMessage method, thereby realizing data sharing and communication. openDataContext provides an independent data sharing and communication environment, so that different pages in the mini game can share and communicate data across pages, so as to better realize the functions and experience in the mini game.
进一步的,所述方法还包括:Furthermore, the method further comprises:
基于所述第一渲染功能接口的接口类型分配第一接口标识,并基于所述第二渲染功能接口的接口类型分配第二接口标识;Allocating a first interface identifier based on the interface type of the first rendering function interface, and allocating a second interface identifier based on the interface type of the second rendering function interface;
基于所述第一接口标识和所述第二接口标识,分别为所述第一渲染功能接口和所述第二渲染功能接口分配对应的着色器资源。Based on the first interface identifier and the second interface identifier, corresponding shader resources are allocated to the first rendering function interface and the second rendering function interface respectively.
由于每个WebGL上下文都有自己的状态、资源、纹理对象以及着色器资源(shaderprogram),虽然WebGL上下文-副不进行渲染,然而其指的是不会渲染到主屏幕上,即不会显示出来,它类似一个屏幕外绘制,因此WebGL上下文-副也要分配着色器资源。具体的,可以根据不同的WebGL上下文,分配不同的接口标识(id),然后根据不同的id来为不同的WebGL上下文获取与分配对应的着色器资源。Since each WebGL context has its own state, resources, texture objects, and shader resources (shaderprogram), although the WebGL context-sub does not render, it does not render to the main screen, that is, it will not be displayed. It is similar to an off-screen drawing, so the WebGL context-sub also needs to allocate shader resources. Specifically, different interface identifiers (ids) can be allocated according to different WebGL contexts, and then different ids can be used to obtain and allocate corresponding shader resources for different WebGL contexts.
进一步的,在创建第二渲染功能接口之后,还包括:Furthermore, after creating the second rendering function interface, it also includes:
基于所述指定全局对象为所述第二渲染功能接口分配对应的着色器资源。Corresponding shader resources are allocated to the second rendering function interface based on the specified global object.
在本申请实施例中,customHitTestBuffer2为WebGL上下文-副的运行环境,因此可以基于customHitTestBuffer2区分WebGL上下文-主和WebGL上下文-副。具体可以基于指定全局对象customHitTestBuffer2为WebGL上下文-副分配对应的着色器资源。In the embodiment of the present application, customHitTestBuffer2 is the operating environment of the WebGL context-secondary, so the WebGL context-primary and the WebGL context-secondary can be distinguished based on customHitTestBuffer2. Specifically, the corresponding shader resources can be allocated to the WebGL context-secondary based on the specified global object customHitTestBuffer2.
步骤102、通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面。Step 102: Render the application interface of the target application through the first rendering function interface to display the application interface.
在本申请实施例中,第一渲染功能接口也即WebGL上下文-主,其主要功能为对目标应用的应用界面进行渲染,以在屏幕上显示所述应用界面,例如对游戏的游戏界面进行渲染,以在屏幕上显示游戏界面。In an embodiment of the present application, the first rendering function interface is also the WebGL context-main, and its main function is to render the application interface of the target application to display the application interface on the screen, for example, to render the game interface of the game to display the game interface on the screen.
步骤103、响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置。Step 103: In response to a trigger operation on the application interface, an operation position of the trigger operation is obtained.
在本申请实施例中,用户可以通过手指或其他物品在屏幕上进行触控操作,从而触发在应用界面的触发操作;或者,用户可以通过操控鼠标或键盘等设备控制指针在应用界面实现触发操作。计算机设备响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置,该操作位置可以为触控操作的位置,也可以为指针被操作时的位置。In the embodiment of the present application, the user can perform a touch operation on the screen with a finger or other object to trigger a trigger operation on the application interface; or the user can control a pointer on the application interface by operating a device such as a mouse or keyboard. In response to the trigger operation on the application interface, the computer device obtains the operation position of the trigger operation, which can be the position of the touch operation or the position of the pointer when it is operated.
步骤104、将所述操作位置命中的所述应用界面上的像素点作为目标像素点。Step 104: taking the pixel point on the application interface hit by the operation position as the target pixel point.
在一具体实施中,步骤“所述将所述操作位置命中的所述应用界面上的像素点作为目标像素点”,包括:In a specific implementation, the step of “taking the pixel point on the application interface hit by the operation position as the target pixel point” includes:
若所述操作位置,命中所述应用界面上的特定界面元素的像素点,将所述像素点作为目标像素点。If the operation position hits a pixel point of a specific interface element on the application interface, the pixel point is used as the target pixel point.
其中,界面元素可以为应用界面上显示的元素,例如虚拟场景、以及虚拟场景中可与用户进行交互的虚拟对象。The interface elements may be elements displayed on the application interface, such as a virtual scene, and virtual objects in the virtual scene that can interact with the user.
具体的,在本申请实施例中,若检测到操作位置,命中所述应用界面上的特定界面元素的像素点,将所述像素点作为目标像素点后,可以调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件,从而进行像素碰撞检测。Specifically, in an embodiment of the present application, if the operation position is detected and the pixel point of a specific interface element on the application interface is hit, after the pixel point is taken as the target pixel point, the second rendering function interface can be called to obtain the target color parameters of the target pixel point, and determine whether the target color parameters meet the preset collision conditions, thereby performing pixel collision detection.
在本申请实施例中,以鼠标的指针是否与界面元素发生像素碰撞进行检测为例进行说明,可以向获取鼠标点击位置的坐标,也即当用户进行鼠标点击操作时,游戏会获取并记录下鼠标点击的坐标。然后,游戏会从显示列表树的根节点开始,遍历列表树的整个树形结构。每个节点代表一个游戏对象。接着,对于每个遍历到的节点,游戏会检查鼠标点击的坐标是否在该节点(游戏对象)的包围盒内。如果在,那么会进一步遍历该节点的子节点。如果鼠标点击的坐标在某个节点的包围盒内,则会进行更精确的碰撞检测,即检查鼠标点击的坐标是否在游戏对象的像素上。如果是,那么就认为鼠标确实点击到了这个游戏对象。In an embodiment of the present application, the detection of whether the mouse pointer has a pixel collision with an interface element is used as an example for explanation. The coordinates of the mouse click position can be obtained, that is, when the user performs a mouse click operation, the game will obtain and record the coordinates of the mouse click. Then, the game will start from the root node of the display list tree and traverse the entire tree structure of the list tree. Each node represents a game object. Then, for each traversed node, the game will check whether the coordinates of the mouse click are within the bounding box of the node (game object). If so, the child nodes of the node will be further traversed. If the coordinates of the mouse click are within the bounding box of a certain node, a more accurate collision detection will be performed, that is, checking whether the coordinates of the mouse click are on the pixels of the game object. If so, it is considered that the mouse has indeed clicked on this game object.
进一步的,可以将该游戏对象的像素点确定的图像对象通过第二渲染功能接口进行绘制,接着判断鼠标点击的像素点的透明度值是否不为0,如果为0,则表示是点击了该游戏对象的透明位置,没有发生像素碰撞;如果不为0,则表示点击了该游戏对象的不透明位置,表明发生了有效的像素碰撞。Furthermore, the image object determined by the pixel points of the game object can be drawn through the second rendering function interface, and then a determination is made as to whether the transparency value of the pixel point clicked by the mouse is not 0. If it is 0, it means that the transparent position of the game object is clicked and no pixel collision occurs; if it is not 0, it means that the opaque position of the game object is clicked, indicating that a valid pixel collision occurs.
步骤105、基于所述目标像素点确定待检测图像对象。Step 105: Determine the image object to be detected based on the target pixel point.
在一实施例中,步骤“所述基于所述目标像素点确定待检测图像对象”,包括:In one embodiment, the step of “determining the image object to be detected based on the target pixel point” includes:
当检测到所述目标像素点对应的图像对象的指定属性的属性值为预设属性值时,确定所述图像对象为待检测图像对象。When it is detected that the attribute value of the designated attribute of the image object corresponding to the target pixel point is a preset attribute value, the image object is determined to be the image object to be detected.
具体的,当检测到所述目标像素点对应的图像对象的指定属性的属性值为预设属性值时,也即图像对象的bOnlyPixelHitTest的属性值为true时,确定所述图像对象为待检测图像对象。Specifically, when it is detected that the attribute value of the designated attribute of the image object corresponding to the target pixel is a preset attribute value, that is, when the attribute value of bOnlyPixelHitTest of the image object is true, it is determined that the image object is the image object to be detected.
步骤106、调用所述第二渲染功能接口绘制所述待检测图像对象。Step 106: Call the second rendering function interface to draw the image object to be detected.
具体的,步骤“所述调用所述第二渲染功能接口绘制所述待检测图像对象”,包括:Specifically, the step of “calling the second rendering function interface to draw the image object to be detected” includes:
调用所述第二渲染功能接口绘制所述待检测图像对象,得到绘制后图像对象。The second rendering function interface is called to draw the image object to be detected to obtain the drawn image object.
例如,可以通过customHitTestBuffer2将待检测图像对象绘制到WebGL上下文-副上,以基于该待检测图像对象进行像素碰撞检测。For example, the image object to be detected can be drawn onto the WebGL context-sub through customHitTestBuffer2, so as to perform pixel collision detection based on the image object to be detected.
具体的,可以获取用户点击位置的目标像素点,调用WebGL上下文-副绘制该目标像素点的待检测图像对象。具体的,可以根据着色器基于customHitTestBuffer2为WebGL上下文-副分配的着色器资源,将待检测图像对象绘制到WebGL上下文-副上,然后根据预设尺寸在绘制后的图像对象上可以获取预设尺寸对应的目标数组,此时,目标数组包括预设尺寸的区域中各像素点的透明值,然后可以从目标数组中获取目标像素点的透明值,来确定是否发送像素碰撞,也即透明值不等于零即表明接触了,也即触发操作与界面元素发生了碰撞。Specifically, the target pixel point at the user click position can be obtained, and the WebGL context-sub can be called to draw the image object to be detected of the target pixel point. Specifically, the image object to be detected can be drawn on the WebGL context-sub according to the shader resources allocated to the WebGL context-sub by the shader based on customHitTestBuffer2, and then the target array corresponding to the preset size can be obtained on the drawn image object according to the preset size. At this time, the target array includes the transparency value of each pixel point in the area of the preset size, and then the transparency value of the target pixel point can be obtained from the target array to determine whether to send a pixel collision, that is, the transparency value is not equal to zero, which indicates contact, that is, the trigger operation collides with the interface element.
步骤107、调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件。Step 107: Call the second rendering function interface to obtain the target color parameter of the target pixel, and determine whether the target color parameter meets a preset collision condition.
具体的,可以通过判断透明值,来确定是否发送像素碰撞,也即透明值不等于零即表明接触了,也即触发操作与界面元素发生了碰撞。其中,预设碰撞条件可以为像素点的透明值不为0。Specifically, the transparency value can be judged to determine whether to send a pixel collision, that is, the transparency value is not equal to zero, which means that there is contact, that is, the trigger operation collides with the interface element. The preset collision condition can be that the transparency value of the pixel point is not zero.
在一实施例中,步骤“所述调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件”,包括:In one embodiment, the step of “calling the second rendering function interface to obtain the target color parameter of the target pixel point, and determining whether the target color parameter satisfies a preset collision condition” includes:
基于所述目标像素点的像素点坐标、以及预设尺寸对所述绘制后图像对象进行数据获取处理,得到目标数组;Performing data acquisition processing on the drawn image object based on the pixel coordinates of the target pixel and a preset size to obtain a target array;
基于所述像素点坐标从所述目标数组确定所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件。A target color parameter of the target pixel is determined from the target array based on the pixel coordinates, and it is determined whether the target color parameter satisfies a preset collision condition.
例如,因为只需要对指定一个点进行像素值的获取,因此不需要申请整个Image对象的宽高尺寸,从而可以减少内存消耗,因此,本申请实施例可以通过矩阵转换坐标并绘制待检测图像对象到WebGL上下文-副上,具体通过customHitTestBuffer2将待检测图像对象绘制到WebGL上下文-副上,得到绘制后图像对象(ImageData对象)。然后,基于所述目标像素点的像素点坐标、以及预设尺寸对所述绘制后图像对象进行数据获取处理,得到目标数组,该目标数组的长度可以为图像宽度×高度×4(每个像素4个通道);具体可以基于操作位置基于预设尺寸3×3在待检测图像对象一个区域,基于该区域确定对应的目标数组;接着,基于所述像素点坐标从所述目标数组确定所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件,具体可以确定目标像素点的位置,并使用以下公式计算在目标数组中的索引:For example, because it is only necessary to obtain the pixel value of a specified point, it is not necessary to apply for the width and height of the entire Image object, thereby reducing memory consumption. Therefore, the embodiment of the present application can transform the coordinates through the matrix and draw the image object to be detected to the WebGL context-sub, and specifically draw the image object to be detected to the WebGL context-sub through customHitTestBuffer2 to obtain the drawn image object (ImageData object). Then, based on the pixel coordinates of the target pixel and the preset size, the drawn image object is processed for data acquisition to obtain a target array, the length of which can be image width × height × 4 (4 channels per pixel); specifically, based on the preset size 3×3 based on the operation position in an area of the image object to be detected, the corresponding target array is determined based on the area; then, based on the pixel coordinates, the target color parameters of the target pixel are determined from the target array, and it is determined whether the target color parameters meet the preset collision conditions. Specifically, the position of the target pixel can be determined, and the index in the target array can be calculated using the following formula:
index=(y×width+x)×4index=(y×width+x)×4
其中,x和y是目标像素点的水平坐标和垂直坐标,width是图像对象的宽度。最后通过上述公式计算出的索引从目标数组中获取目标像素点对应的目标颜色值,也即RGBA值,从而获取到一个数组[r,g,b,a],其中的元素分别代表该像素点的红色值、绿色值、蓝色值以及透明值。最终通过判断透明值,来确定是否发送碰撞,也即透明值不等于零即表明接触了,也即触发操作与界面元素发生了碰撞。Among them, x and y are the horizontal and vertical coordinates of the target pixel, and width is the width of the image object. Finally, the target color value corresponding to the target pixel is obtained from the target array through the index calculated by the above formula, that is, the RGBA value, so as to obtain an array [r, g, b, a], in which the elements represent the red value, green value, blue value and transparency value of the pixel respectively. Finally, by judging the transparency value, it is determined whether to send a collision. That is, if the transparency value is not equal to zero, it means that there is contact, which means that the trigger operation has collided with the interface element.
步骤108、若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。Step 108: If the target color parameter satisfies the preset collision condition, it is determined that a pixel collision occurs between the trigger operation and the image object to be detected.
具体的,所述目标颜色参数包括目标透明值;步骤“所述确定所述目标颜色参数是否满足预设碰撞条件”,包括:Specifically, the target color parameter includes a target transparency value; the step of “determining whether the target color parameter satisfies a preset collision condition” includes:
调用所述第二渲染功能接口获取所述目标像素点的目标透明值,并确定所述目标透明值是否为指定参考透明值;Calling the second rendering function interface to obtain a target transparency value of the target pixel, and determining whether the target transparency value is a specified reference transparency value;
若否,则确定所述触发操作与所述待检测图像对象发生了像素碰撞。If not, it is determined that a pixel collision occurs between the trigger operation and the image object to be detected.
例如,预设碰撞条件可以为像素点的透明值不为0,若像素值的透明度值不为0则满足预设碰撞条件,从而表示触发操作与所述待检测图像对象发生了像素碰撞;若像素值的透明度值为0则满足预设碰撞条件,从而表示触发操作与所述待检测图像对象没有发生像素碰撞。For example, the preset collision condition may be that the transparency value of the pixel point is not 0. If the transparency value of the pixel value is not 0, the preset collision condition is met, indicating that a pixel collision has occurred between the trigger operation and the image object to be detected; if the transparency value of the pixel value is 0, the preset collision condition is met, indicating that no pixel collision has occurred between the trigger operation and the image object to be detected.
本申请实施例可以通过修改Egret引擎代码,使Egret引擎支持创建两个WebGL上下文,解决了Egret引擎在特定环境下无法进行像素检测的问题。这样即使在特定环境下,Egret引擎也能够进行精确的像素检测,从而提高了游戏的真实感和玩家的游戏体验。The embodiment of the present application can modify the Egret engine code to enable the Egret engine to support the creation of two WebGL contexts, thereby solving the problem that the Egret engine cannot perform pixel detection under certain circumstances. In this way, even under certain circumstances, the Egret engine can perform accurate pixel detection, thereby improving the realism of the game and the game experience of the players.
然后,可以通过在Image对象中添加新的属性控制,使得Image对象可以被用于像素检测而不会被渲染出来。从而解决了在WebGL1.0情况下,不同WebGL上下文使用到对应的纹理。这样可以避免不必要的渲染,从而提高了游戏的运行效率。Then, by adding new property controls to the Image object, the Image object can be used for pixel detection without being rendered. This solves the problem of using corresponding textures for different WebGL contexts in WebGL1.0. This avoids unnecessary rendering and improves the running efficiency of the game.
并且,通过在Egret引擎中声明一个全局对象,并在应用小游戏平台上创建该全局对象,使得Egret引擎能够在微信小游戏平台上进行像素检测。这样可以扩大Egret引擎的应用范围,使其能够在更多的平台上进行像素检测。Furthermore, by declaring a global object in the Egret engine and creating the global object on the application mini-game platform, the Egret engine can perform pixel detection on the WeChat mini-game platform. This can expand the application scope of the Egret engine and enable it to perform pixel detection on more platforms.
最后,通过在Egret引擎原先的对于一个Image对象进行像素检测函数中进行修改,使得当发现该全局对象存在时并且该Image对象的特定属性值等于true时,则进入使用WebGL上下文-副来绘制该Image对象。这样可以在特定环境下实现像素检测,从而提高了游戏的真实感和玩家的游戏体验;同时,对于上层业务代码无需做任何修改,减少接入成本。Finally, by modifying the original pixel detection function for an Image object in the Egret engine, when the global object is found to exist and the specific attribute value of the Image object is equal to true, the WebGL context is used to draw the Image object. In this way, pixel detection can be implemented in a specific environment, thereby improving the realism of the game and the gaming experience of the players; at the same time, no modification is required to the upper-level business code, reducing the access cost.
本实施例还提供一种碰撞检测装置,该碰撞检测装置具体可以集成在终端设备中。例如,如图3所示,该碰撞检测装置可以包括:This embodiment also provides a collision detection device, which can be integrated in a terminal device. For example, as shown in FIG3 , the collision detection device may include:
创建单元201,用于启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;A creation unit 201 is used to start a game engine, create a first rendering function interface, and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering;
第一调用单元202,用于通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;A first calling unit 202 is used to render an application interface of a target application through the first rendering function interface to display the application interface;
响应单元203,用于响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;A response unit 203, configured to obtain an operation position of the trigger operation in response to the trigger operation on the application interface;
处理单元204,用于将所述操作位置命中的所述应用界面上的像素点作为目标像素点;A processing unit 204 is configured to use the pixel point on the application interface hit by the operation position as a target pixel point;
第一确定单元205,用于基于所述目标像素点确定待检测图像对象;A first determining unit 205, configured to determine an image object to be detected based on the target pixel point;
第二调用单元206,用于调用所述第二渲染功能接口绘制所述待检测图像对象;The second calling unit 206 is used to call the second rendering function interface to draw the image object to be detected;
第三调用单元207,还调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;The third calling unit 207 further calls the second rendering function interface to obtain a target color parameter of the target pixel point, and determines whether the target color parameter satisfies a preset collision condition;
第二确定单元208,用于若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。The second determining unit 208 is configured to determine whether a pixel collision occurs between the trigger operation and the image object to be detected if the target color parameter satisfies the preset collision condition.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
设置子单元,用于为所述第二渲染功能接口对应的图像对象设置指定属性,其中,所述指定属性用于指示所述图像对象不会被渲染、以使所述图像对象用于进行像素碰撞检测。A setting subunit is used to set a specified attribute for the image object corresponding to the second rendering function interface, wherein the specified attribute is used to indicate that the image object will not be rendered so that the image object is used for pixel collision detection.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第一检测子单元,用于当检测到所述目标像素点对应的图像对象的指定属性的属性值为预设属性值时,确定所述图像对象为待检测图像对象。The first detection subunit is configured to determine that the image object is an image object to be detected when it is detected that the attribute value of the designated attribute of the image object corresponding to the target pixel point is a preset attribute value.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第一调用子单元,用于调用所述第二渲染功能接口绘制所述待检测图像对象,得到绘制后图像对象。The first calling subunit is used to call the second rendering function interface to draw the image object to be detected to obtain the drawn image object.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第一处理子单元,用于基于所述目标像素点的像素点坐标、以及预设尺寸对所述绘制后图像对象进行数据获取处理,得到目标数组;A first processing sub-unit is used to perform data acquisition processing on the drawn image object based on the pixel coordinates of the target pixel and a preset size to obtain a target array;
第一确定子单元,用于基于所述像素点坐标从所述目标数组确定所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件。The first determining subunit is used to determine a target color parameter of the target pixel point from the target array based on the pixel point coordinates, and to determine whether the target color parameter satisfies a preset collision condition.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第二确定子单元,用于确定所述目标透明值是否为指定参考透明值;A second determination subunit, configured to determine whether the target transparency value is a specified reference transparency value;
第二确定子单元,用于若否,则确定所述触发操作与所述待检测图像对象发生了像素碰撞。The second determining subunit is configured to determine, if not, whether a pixel collision occurs between the triggering operation and the image object to be detected.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
创建子单元,用于创建指定全局对象,所述指定全局对象用于使所述第二渲染功能接口可绘制所述图像对象。A creation subunit is used to create a specified global object, where the specified global object is used to enable the second rendering function interface to draw the image object.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第二检测子单元,用于当检测到存在所述指定全局对象,且所述待检测图像对象的指定属性的属性值为预设属性值时,基于所述指定全局对象绘制所述待检测图像对象。The second detection subunit is configured to draw the image object to be detected based on the designated global object when it is detected that the designated global object exists and the attribute value of the designated attribute of the image object to be detected is a preset attribute value.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
分配子单元,用于基于所述指定全局对象为所述第二渲染功能接口分配对应的着色器资源。An allocation subunit is used to allocate corresponding shader resources to the second rendering function interface based on the specified global object.
在一些实施例中,该碰撞检测装置包括:In some embodiments, the collision detection device comprises:
第二处理子单元,用于若所述操作位置,命中所述应用界面上的特定界面元素的像素点,将所述像素点作为目标像素点。The second processing sub-unit is used for, if the operation position hits a pixel point of a specific interface element on the application interface, taking the pixel point as a target pixel point.
本申请实施例公开了一种碰撞检测装置,通过创建单元201启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;第一调用单元202通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;响应单元203响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;处理单元204将所述操作位置命中的所述应用界面上的像素点作为目标像素点;第一确定单元205基于所述目标像素点确定待检测图像对象;第二调用单元206调用所述第二渲染功能接口绘制所述待检测图像对象;第三调用单元207用于调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;第二确定单元208若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。本申请实施例可以通过创建两个渲染功能接口,一个渲染功能接口用于进行界面渲染等操作,另一个渲染功能接口用于进行像素碰撞检测的操作,从而可以使游戏引擎在特定应用平台运行游戏时可以正常进行像素碰撞检测,提高了碰撞检测的精准性,提高了玩家在特定应用平台进行游戏时游戏交互的准确性,提升了玩家的游戏体验。The embodiment of the present application discloses a collision detection device, which starts a game engine through a creation unit 201, creates a first rendering function interface and a second rendering function interface, and the second rendering function interface is configured to be unable to perform screen rendering; a first calling unit 202 renders an application interface of a target application through the first rendering function interface to display the application interface; a response unit 203 obtains an operation position of the trigger operation in response to a trigger operation on the application interface; a processing unit 204 uses a pixel point on the application interface hit by the operation position as a target pixel point; a first determination unit 205 determines an image object to be detected based on the target pixel point; a second calling unit 206 calls the second rendering function interface to draw the image object to be detected; a third calling unit 207 is used to call the second rendering function interface to obtain a target color parameter of the target pixel point, and determine whether the target color parameter meets a preset collision condition; a second determination unit 208 determines that a pixel collision has occurred between the trigger operation and the image object to be detected if the target color parameter meets the preset collision condition. The embodiment of the present application can create two rendering function interfaces, one rendering function interface is used to perform operations such as interface rendering, and the other rendering function interface is used to perform pixel collision detection operations, so that the game engine can perform pixel collision detection normally when running the game on a specific application platform, thereby improving the accuracy of collision detection, improving the accuracy of game interaction when players play games on a specific application platform, and enhancing the player's gaming experience.
相应的,本申请实施例还提供一种电子设备,该电子设备可以为终端,该终端可以为智能手机、平板电脑、笔记本电脑、触控屏幕、游戏机、个人计算机(PC,PersonalComputer)、个人数字助理(Personal Digital Assistant,PDA)等终端设备。或者,电子设备可以为服务器。Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
如图4所示,图4为本申请实施例提供的电子设备的结构示意图。该电子设备300包括有一个或者一个以上处理核心的处理器301、有一个或一个以上计算机可读存储介质的存储器302及存储在存储器302上并可在处理器上运行的计算机程序。其中,处理器301与存储器302电性连接。本领域技术人员可以理解,图中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。As shown in Figure 4, Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. Among them, the processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
处理器301是电子设备300的控制中心,利用各种接口和线路连接整个电子设备300的各个部分,通过运行或加载存储在存储器302内的软件程序和/或单元,以及调用存储在存储器302内的数据,执行电子设备300的各种功能和处理数据,从而对电子设备300进行整体监控。处理器301可以是中央处理器CPU、图形处理器GPU、网络处理器(NetworkProcessor,NP)等,可以实现或者执行本申请实施例中公开的各方法、步骤及逻辑框图。The processor 301 is the control center of the electronic device 300, and uses various interfaces and lines to connect various parts of the entire electronic device 300. By running or loading software programs and/or units stored in the memory 302, and calling data stored in the memory 302, the processor 301 executes various functions of the electronic device 300 and processes data, thereby monitoring the electronic device 300 as a whole. The processor 301 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
在本申请实施例中,电子设备300中的处理器301会按照如下的步骤,将一个或一个以上的应用程序的进程对应的指令加载到存储器302中,并由处理器301来运行存储在存储器302中的应用程序,从而实现各种功能,例如:In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions, such as:
启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;Starting a game engine, creating a first rendering function interface and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering;
通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;Rendering the application interface of the target application through the first rendering function interface to display the application interface;
响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;In response to a trigger operation on the application interface, obtaining an operation position of the trigger operation;
将所述操作位置命中的所述应用界面上的像素点作为目标像素点;Taking the pixel point on the application interface hit by the operation position as the target pixel point;
基于所述目标像素点确定待检测图像对象;Determine the image object to be detected based on the target pixel point;
调用所述第二渲染功能接口绘制所述待检测图像对象;Calling the second rendering function interface to draw the image object to be detected;
调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;Calling the second rendering function interface to obtain a target color parameter of the target pixel point, and determining whether the target color parameter satisfies a preset collision condition;
若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。If the target color parameter satisfies the preset collision condition, it is determined that a pixel collision occurs between the trigger operation and the image object to be detected.
本申请实施例提供的电子设备,可以通过启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;然后,通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;接着,响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;之后,将所述操作位置命中的所述应用界面上的像素点作为目标像素点;接着,基于所述目标像素点确定待检测图像对象;然后,调用所述第二渲染功能接口绘制所述待检测图像对象;之后,调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;最后,若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。采用本申请实施例的方案,可以通过创建两个渲染功能接口,一个渲染功能接口用于进行界面渲染等操作,另一个渲染功能接口用于进行像素碰撞检测的操作,从而可以使游戏引擎在特定应用平台运行游戏时可以正常进行像素碰撞检测,提高了碰撞检测的精准性,提高了玩家在特定应用平台进行游戏时游戏交互的准确性,提升了玩家的游戏体验。The electronic device provided in the embodiment of the present application can create a first rendering function interface and a second rendering function interface by starting a game engine, and the second rendering function interface is configured to be unable to perform screen rendering; then, the application interface of the target application is rendered through the first rendering function interface to display the application interface; then, in response to a trigger operation on the application interface, the operation position of the trigger operation is obtained; then, the pixel point on the application interface hit by the operation position is used as the target pixel point; then, the image object to be detected is determined based on the target pixel point; then, the second rendering function interface is called to draw the image object to be detected; then, the second rendering function interface is called to obtain the target color parameter of the target pixel point, and it is determined whether the target color parameter meets the preset collision condition; finally, if the target color parameter meets the preset collision condition, it is determined that the trigger operation has a pixel collision with the image object to be detected. By adopting the solution of the embodiment of the present application, two rendering function interfaces can be created, one rendering function interface is used to perform operations such as interface rendering, and the other rendering function interface is used to perform pixel collision detection operations, so that the game engine can perform pixel collision detection normally when running the game on a specific application platform, thereby improving the accuracy of collision detection, improving the accuracy of game interaction when players play games on a specific application platform, and enhancing the player's gaming experience.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
可选的,如图4所示,电子设备300还包括:触控显示屏303、射频电路304、音频电路305、输入单元306以及电源307。其中,处理器301分别与触控显示屏303、射频电路304、音频电路305、输入单元306以及电源307电性连接。本领域技术人员可以理解,图4中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Optionally, as shown in FIG4 , the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307, respectively. Those skilled in the art will appreciate that the electronic device structure shown in FIG4 does not limit the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
触控显示屏303可用于显示图形用户界面以及接收用户作用于图形用户界面产生的操作指令。触控显示屏303可以包括显示面板和触控面板。其中,显示面板可用于显示由用户输入的信息或提供给用户的信息以及电子设备的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。可选的,可以采用液晶显示器(LCD,Liquid Crystal Display)、有机发光二极管(OLED,Organic Light-Emitting Diode)等形式来配置显示面板。触控面板可用于收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板上或在触控面板附近的操作),并生成相应的操作指令,且操作指令执行对应程序。可选的,触控面板可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器301,并能接收处理器301发来的命令并加以执行。触控面板可覆盖显示面板,当触控面板检测到在其上或附近的触摸操作后,传送给处理器301以确定触摸事件的类型,随后处理器301根据触摸事件的类型在显示面板上提供相应的视觉输出。在本申请实施例中,可以将触控面板与显示面板集成到触控显示屏303而实现输入和输出功能。但是在某些实施例中,触控面板与触控面板可以作为两个独立的部件来实现输入和输出功能。即触控显示屏303也可以作为输入单元306的一部分实现输入功能。The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event, and then the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to realize the input function.
射频电路304可用于收发射频信号,以通过无线通信与网络设备或其他电子设备建立无线通讯,与网络设备或其他电子设备之间收发信号。The radio frequency circuit 304 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device or other electronic devices.
音频电路305可以用于通过扬声器、传声器提供用户与电子设备之间的音频接口。音频电路305可将接收到的音频数据转换后的电信号,传输到扬声器,由扬声器转换为声音信号输出;另一方面,传声器将收集的声音信号转换为电信号,由音频电路305接收后转换为音频数据,再将音频数据输出处理器301处理后,经射频电路304以发送给比如另一电子设备,或者将音频数据输出至存储器302以便进一步处理。音频电路305还可能包括耳塞插孔,以提供外设耳机与电子设备的通信。The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
输入单元306可用于接收输入的数字、字符信息或用户特征信息(例如指纹、虹膜、面部信息等),以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。The input unit 306 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
电源307用于给电子设备300的各个部件供电。可选的,电源307可以通过电源管理系统与处理器301逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源307还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
尽管图4中未示出,电子设备300还可以包括摄像头、传感器、无线保真模块、蓝牙模块等,在此不再赘述。Although not shown in FIG. 4 , the electronic device 300 may further include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail herein.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过指令来完成,或通过指令控制相关的硬件来完成,该指令可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
为此,本申请实施例提供一种计算机可读存储介质,其中存储有多条计算机程序,该计算机程序能够被处理器进行加载,以执行本申请实施例所提供的任一种碰撞检测方法。该计算机程序可以执行如下碰撞检测方法的步骤:To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any collision detection method provided in the embodiment of the present application. The computer program can execute the following steps of the collision detection method:
启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;Starting a game engine, creating a first rendering function interface and a second rendering function interface, wherein the second rendering function interface is configured to be unable to perform screen rendering;
通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;Rendering the application interface of the target application through the first rendering function interface to display the application interface;
响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;In response to a trigger operation on the application interface, obtaining an operation position of the trigger operation;
将所述操作位置命中的所述应用界面上的像素点作为目标像素点;Taking the pixel point on the application interface hit by the operation position as the target pixel point;
基于所述目标像素点确定待检测图像对象;Determine the image object to be detected based on the target pixel point;
调用所述第二渲染功能接口绘制所述待检测图像对象;Calling the second rendering function interface to draw the image object to be detected;
调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;Calling the second rendering function interface to obtain a target color parameter of the target pixel point, and determining whether the target color parameter satisfies a preset collision condition;
若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。If the target color parameter satisfies the preset collision condition, it is determined that a pixel collision occurs between the trigger operation and the image object to be detected.
由于该存储介质中所存储的计算机程序,可以通过启动游戏引擎,创建第一渲染功能接口、以及第二渲染功能接口,所述第二渲染功能接口被配置为无法进行屏幕渲染;然后,通过所述第一渲染功能接口对目标应用的应用界面进行渲染,以显示所述应用界面;接着,响应于针对所述应用界面的触发操作,获取所述触发操作的操作位置;之后,将所述操作位置命中的所述应用界面上的像素点作为目标像素点;接着,基于所述目标像素点确定待检测图像对象;然后,调用所述第二渲染功能接口绘制所述待检测图像对象;之后,调用所述第二渲染功能接口获取所述目标像素点的目标颜色参数,并确定所述目标颜色参数是否满足预设碰撞条件;最后,若所述目标颜色参数满足所述预设碰撞条件,确定所述触发操作与所述待检测图像对象发生了像素碰撞。采用本申请实施例的方案,可以通过创建两个渲染功能接口,一个渲染功能接口用于进行界面渲染等操作,另一个渲染功能接口用于进行像素碰撞检测的操作,从而可以使游戏引擎在特定应用平台运行游戏时可以正常进行像素碰撞检测,提高了碰撞检测的精准性,提高了玩家在特定应用平台进行游戏时游戏交互的准确性,提升了玩家的游戏体验。Due to the computer program stored in the storage medium, a first rendering function interface and a second rendering function interface can be created by starting a game engine, and the second rendering function interface is configured to be unable to perform screen rendering; then, the application interface of the target application is rendered through the first rendering function interface to display the application interface; then, in response to a trigger operation on the application interface, the operation position of the trigger operation is obtained; then, the pixel point on the application interface hit by the operation position is used as the target pixel point; then, the image object to be detected is determined based on the target pixel point; then, the second rendering function interface is called to draw the image object to be detected; then, the second rendering function interface is called to obtain the target color parameter of the target pixel point, and it is determined whether the target color parameter meets the preset collision condition; finally, if the target color parameter meets the preset collision condition, it is determined that the trigger operation has a pixel collision with the image object to be detected. By adopting the solution of the embodiment of the present application, two rendering function interfaces can be created, one rendering function interface is used to perform operations such as interface rendering, and the other rendering function interface is used to perform pixel collision detection operations, so that the game engine can perform pixel collision detection normally when running the game on a specific application platform, thereby improving the accuracy of collision detection, improving the accuracy of game interaction when players play games on a specific application platform, and enhancing the player's gaming experience.
以上各个操作的具体实施可参见前面的实施例,在此不再赘述。The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
其中,该计算机可读存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
由于该计算机可读存储介质中所存储的计算机程序,可以执行本申请实施例所提供的任一种碰撞检测方法,因此,可以实现本申请实施例所提供的任一种碰撞检测方法所能实现的有益效果,详见前面的实施例,在此不再赘述。Since the computer program stored in the computer-readable storage medium can execute any collision detection method provided in the embodiments of the present application, the beneficial effects that can be achieved by any collision detection method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
根据本申请的一个方面,还提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。电子设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该电子设备执行上述实施例中的各种可选实现方式中提供的方法。According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
在上述碰撞检测装置、计算机可读存储介质、电子设备、计算机程序产品实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的碰撞检测装置、计算机可读存储介质、计算机程序产品、电子设备及其相应单元的具体工作过程及可带来的有益效果,可以参考如上实施例中碰撞检测方法的说明,具体在此不再赘述。In the above-mentioned collision detection device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-mentioned collision detection device, computer-readable storage medium, computer program product, electronic device and its corresponding units can refer to the description of the collision detection method in the above embodiment, and will not be repeated here.
以上对本申请实施例所提供的一种碰撞检测方法、装置、电子设备、计算机可读存储介质以及计算机程序产品进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。The above is a detailed introduction to a collision detection method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims (13)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411067550.5A CN118873942A (en) | 2024-08-05 | 2024-08-05 | A collision detection method, device, electronic device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202411067550.5A CN118873942A (en) | 2024-08-05 | 2024-08-05 | A collision detection method, device, electronic device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118873942A true CN118873942A (en) | 2024-11-01 |
Family
ID=93234876
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202411067550.5A Pending CN118873942A (en) | 2024-08-05 | 2024-08-05 | A collision detection method, device, electronic device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118873942A (en) |
-
2024
- 2024-08-05 CN CN202411067550.5A patent/CN118873942A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA3133915A1 (en) | Virtual object control method and apparatus, device, and storage medium | |
JP7387758B2 (en) | Interface display method, device, terminal, storage medium and computer program | |
US11810234B2 (en) | Method and apparatus for processing avatar usage data, device, and storage medium | |
CN113952720B (en) | Game scene rendering method, device, electronic device and storage medium | |
CN111672111A (en) | Interface display method, device, equipment and storage medium | |
CN111905363A (en) | Virtual object control method, device, terminal and storage medium | |
CN111672117B (en) | Virtual object selection method, device, equipment and storage medium | |
JP7686914B2 (en) | Method for selecting a virtual object, and device, terminal, and storage medium thereof | |
CN110801629B (en) | Method, device, terminal and medium for displaying virtual object life value prompt graph | |
CN115300904A (en) | Recommendation method and device, electronic equipment and storage medium | |
KR20240149954A (en) | Message display method, device, apparatus, medium and program product | |
CN118873942A (en) | A collision detection method, device, electronic device and storage medium | |
CN113509730B (en) | Information preview method, device, equipment and storage medium | |
CN113440842B (en) | Content display method, device, terminal and storage medium | |
CN119607556A (en) | A method, device, electronic device and storage medium for controlling virtual props | |
CN116549972A (en) | Virtual resource processing method, device, computer equipment and storage medium | |
CN119048209A (en) | Game resource transaction method and device, electronic equipment and storage medium | |
CN119680202A (en) | Virtual object model processing method, device, electronic device and storage medium | |
CN120346526A (en) | Virtual object assembly method and device, electronic equipment and storage medium | |
CN120550412A (en) | A method, device, electronic device and storage medium for generating game equipment | |
CN119499639A (en) | Game interaction method, device, electronic device and storage medium | |
CN115888100A (en) | Game display control method, device, electronic device and storage medium | |
HK40028881B (en) | Method and device for selecting virtual object, terminal and storage medium | |
HK40028881A (en) | Method and device for selecting virtual object, terminal and storage medium | |
HK40028514B (en) | Method and apparatus for selecting virtual object, device and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |