Cocos2d which spirit was touched




















The next chapter will talk about Cocos All kinds of technical terms. After that, I will cross the entry bar. Enter intermediate development. In the last chapter, I've learned how to build the environment. This chapter is about mastering the basic concepts.

It's about : 1. The director 2. The director Director The main role of a director's existence : a. Environment setting Frame rate initialization ope The second part of the code area is shown below 68 Row position , butt Link to this article :h The lights went out yesterday. So how is receiving layer to the player's touch event of it?

It IOS system and how to interact? The answer in CCTouchDispatcher this class. CCTouchDispatcher a single example, just started the program, the director class will set EAGLView touch proxy, when the player has touch operation, the system will automatically call its corresponding method. When the previously mentioned layer is too described, by CCLayer registerWithTouchDispatcher method to register itself CCTouchDispatcher single embodiment, upon detection of touch information CCTouchDispatcher, traverses these objects in the queue registration, call their response method so that they can respond to touch event.

To introduce the following variables and methods of CCTouchDispatcher. Standard registration queue, in fact, an array, when CCLayer object calls registerWithTouchDispatcher method, it is added to the array of all the objects in the array will be called its related methods when the player touches the screen, these methods ccTouchesBegan : withEvent: , ccTouchesMoved: withEvent: , ccTouchesEnded: withEvent : and ccTouchesCancelled: withEvent :.

Target registration queue, and also as standardHandlers array, its role and standardHandlers much the same, the only difference is targetedHandlers could "swallow" its own event response in order to prevent the information passed on down, and standardHandlers not have this feature. CCMenu is registered to the queue. Is locked when the player made a touch operation, when CCTouchDispatcher traversing the registration queue, the variable is set to YES, this time is not to add new objects to the queue, or remove objects from the queue only when traversing end , locked after being set back to NO, you can add or delete, if carried out two operations in the locking process, the operation object will be placed in the temporary queue corresponding, then sync them to Unlocked registration queue.

Is there an object waiting to add, when CCTouchDispatcher is locked, if there is a new object to be registered come in, it will be added to a temporary queue, the queue are all members of the object to be registered, if the queue is not empty, toAdd on value is YES, then when the lock is released, all the members of the queue will all move standardHandlers or targetedHandlers which will distinguish itself according to the type of object , after the emptying operation is complete the temporary queue, set back TOADD NO.

Is there a deleted object wait, add the same as when it is locked in CCTouchDispatcher, need to remove the object will be placed in another temporary queue, the queue members are waiting for cancellation, if the queue is not empty, toRemove will be is YES, then the lock release queue member so removed from the registration queue queue will automatically determine which specific , the operation is completed empty the temporary queue, toRemove set back to NO.

Temporary storage queue waiting queue registering objects, as described earlier, this array is stored to be registered object. Store queue waiting for cancellation of the object, as described earlier, this array is stored temporarily pending write-off queue object.

Do you want to empty the registration queue, like toRemove, empty the queue also have to wait until after the unlock to perform, this variable is whether the need to empty the mark. When the touch operation, whether the registration queue traversal by default has been YES, when it needs to be manually set to NO.

Subscription column. Cocos2d-x game development practice. Header file gamemain. If necessary, take the above yourself, change the picture and class name.

Sweep and share posters. Column catalog. Add code slice. Can also input one thousand Characters. Paid in element. Click retrieve. Code scanning payment. Wallet balance 0 Deduction Description: 1.



0コメント

  • 1000 / 1000