cocos2d python sprite 响应mouse 事件
2012-07-09 21:18
429 查看
记录下关键代码
不多说明,一看就明白
不多说明,一看就明白
class card_sprite(Sprite): is_event_handler=True; def __init__(self,image): super(card_sprite,self).__init__(image); self.is_mouse=False; self.is_end=False; def on_enter(self): super(card_sprite,self).on_enter(); director.window.push_handlers(self.on_mouse_press); def on_exit(self): director.window.pop_handlers(); super(card_sprite,self).on_exit(); def on_mouse_press(self,x,y,buttons,modifiers): if self.is_mouse==True: if buttons== 1 and x>(self.x-self.width/2) and x<=(self.x-self.width/2+20) and y>=(self.y-self.height/2) and y<=(self.y +self.height/2): print "click!!!!11"; return; if self.is_end==True: if buttons== 1 and x>(self.x-self.width/2) and x<=(self.x-self.width/2+90) and y>=(self.y-self.height/2) and y<=(self.y +self.height/2): print 'is end click()'; return ;
相关文章推荐
- Cocos2d-iphone 为sprite添加双击的事件响应
- Cocos2d-iphone 为sprite添加双击的事件响应
- Cocos2d-iphone 为sprite添加双击的事件响应
- cocos2d-x 界面编程三(cocos2d-x2.22版本中cocostudio GUI的控件事件响应)
- cocos2d-x 3.0 点击button,点击事件响应两次
- Python wxpython模块响应鼠标拖动事件操作示例
- 【Cocos2d-x学习笔记】之响应触屏事件
- cocos2d-x让win32响应键盘事件
- Cocos2d-x中CCTableView关于点击空白区域依然会响应单元格事件
- cocos2d 事件响应
- Cocos2d-x 3.0 Lua编程 之 响应物理引擎的Contact事件回调不运行的问题
- cocos2d-html5学习之三-为sprite添加触摸事件
- cocos2d-x让win32响应键盘事件
- python调用win32com创建可响应应用事件的文档对象
- Cocos2d-x 响应按下事件
- cocos2d屏幕部分区域无法响应触摸事件
- Cocos2d-x 触摸响应事件CCTouchDelegate
- python基于pygame实现响应游戏中事件的方法(附源码)
- cocos2d for python action mouse
- cocos2d-x中解决点击事件上层响应,下层不响应