![]() WinSize = CCDirector::sharedDirector()->getWinSize() ĬCSprite* sl = CCSprite::create(s_loading) ĬCSprite* logo = CCSprite::create(s_logo) Open RopeSprite.Jieyaozu/FightingSolarSystem // on "init" you need to initialize your instanceĬCTexture2D *shipTexture = CCTextureCache::sharedTextureCache()->addImage(s_ship01) ĬostomeKeyPadDelegae *keyDelegate = new CostomeKeyPadDelegae() ĬCDirector::sharedDirector()->getKeypadDispatcher()->addDelegate(keyDelegate) Since fingers are larger than the ropes, you will want to add a little bit of buffer around the two anchor points, just to be sure. Since the rope is of finite length, you’ll need one extra check - to see if the user touched within the bounding box of the rope. But there isn’t quite enough room on your screen for a rope of that size - not even on your 27″ Thunderbolt display, sadly. The calculations above work for the general case of a rope of infinite length. You know what they say about theory - it works perfectly, in theory. You next calculate the intersection point of the two lines, and then you calculate the distance between the intersection point and the touch location. The orthogonal line will always represent the shortest distance possible between the point and the line. To calculate the distance between a point and a line, simply construct two lines: one that goes through both anchor points of the rope, and another which is orthogonal, or perpendicular, to the first and passes through the touch location. To understand what makes this touch detection more complicated, take a look at the following graphic:īasic geometry helps you to calculate the distance between the touch location and the rope. The tricky bit is knowing if a rope was selected it’s not quite as straightforward as clicking on pineapples. ![]() ![]() Most of the steps are quite straightforward, and you likely already know everything you need in order to implement these methods on your own. Delete copy from the list in level editor.Delete model from the level file handler.Remove the visual object from the scene.Detect which object was touched or selected by the user. ![]() Think for a minute about the steps required to delete an object in your level: Looks like you’re going to need some object deletion methods. The ability to add objects to the screen is pretty rewarding, but your screen is getting more crowded by the second and - whoops! You anchored a rope where you didn’t mean to. Getting Started: Removing Objects From Your Level This project starts where you left off in the last tutorial, so make sure you have a copy of the project from part 2. In this last portion of the tutorial, you’ll add the ability to delete objects, move them around, complete the level save and reset mechanism, and implement multiple level handling to round out your level editor! Then you finished off by adding the ability to create new objects and place them on the screen. ![]() In the second part, you added a popup menu along with a state machine to control the flow of the editor and provide a visual indicator of the current mode of the editor. In the first part of this three-part tutorial, you designed the XML storage mechanism of your level files, implemented some model classes to hold your rope and pineapple data, and finished off by creating the load file functionality of your level editor. Welcome to the third part of a tutorial series that shows you how to make a level editor for the Cut the Verlet game that was previously covered on this site. ![]()
0 Comments
Leave a Reply. |