我正在尝试使用Cocos2d为iPhone开发游戏。我需要在Cocos2d中有“拖拽”选项。是否可以在Cocos2d中实现拖拽选项?
我该如何在Cocos2d中实现“拖动”选项?
原标题:
最佳回答
做得很好。
-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView: [touch view]];
CGPoint convertedLocation = [[Director sharedDirector] convertCoordinate:location];
//start ur logical code
}
问题回答
To drag you can simply set the sprite s center to the location of the current touch coordinates.
看看苹果开发者示例:MoveMe。我认为这会有帮助。
你是否想要创建像《飞行管制》或《港口大师》一样的寻路游戏?请详细解释一下你想要实现的内容。
相关问题
热门标签
- winforms
- combobox
- fogbugz
- java
- date
- internationalization
- asp.net
- iis
- url-rewriting
- urlrewriter
- c#
- enums
- ocaml
- haxe
- algorithm
- string
- viewstate
- .net
- c++
- c
- symbol-table
- mysql
- database
- postgresql
- licensing
- migration
- vb.net
- vb6
- declaration
- vb6-migration
- python
- psycopg2
- backup
- vmware
- virtualization
- gnu-screen
- authentication
- desktop
- excel
- xll
- cultureinfo
- regioninfo
- oracle
- client
- session
- download
- html
- virtual
- constructor
- scenarios
- perl
- full-text-search
- javascript
- ajax
- testing
- oop
- inheritance
- vim
- encapsulation
- information-hiding