本文整理汇总了Python中pygame.MOUSEBUTTONUP属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.MOUSEBUTTONUP属性的具体用法?Python pygame.MOUSEBUTTONUP怎么用?Python pygame.MOUSEBUTTONUP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.MOUSEBUTTONUP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleEvents
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handleEvents(self):
self.mouse = self.get(MOUSE)
for event, pos in self.context.events:
self.mouse = pos
handled = self.mode.handleEvent((event, pos))
if not handled:
if event.type == pygame.MOUSEBUTTONDOWN:
self.handleMouseDown(event, pos)
elif event.type == pygame.MOUSEMOTION:
self.handleMouseMotion(pos)
elif event.type == pygame.MOUSEBUTTONUP:
self.handleMouseUp(pos)
if self.mouse:
self.set(MOUSE, self.mouse)
示例2: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if event.type == pygame.MOUSEBUTTONDOWN:
self.active_item = self.board.ships[self.board.active_ship]
if self.active_item.unit_id < 20:
self.current_letter_index = self.active_item.unit_id
self.activate_letter()
else:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
if self.lt.rect.topleft[0] < pos[0] < self.lt.rect.topleft[0] + self.lt.rect.width and \
self.lt.rect.topleft[1] < pos[1] < self.lt.rect.topleft[
1] + self.lt.rect.height:
self.next_slide(-1)
elif self.rt.rect.topleft[0] < pos[0] < self.rt.rect.topleft[0] + self.rt.rect.width and \
self.rt.rect.topleft[1] < pos[1] < self.rt.rect.topleft[
1] + self.rt.rect.height:
self.next_slide(1)
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
self.default_hover(event)
示例3: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handle(self, event):
gd.BoardGame.handle(self, event)
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONUP:
pos = [event.pos[0] - self.layout.game_left, event.pos[1] - self.layout.top_margin]
found = False
for each in self.units:
if (each.rect.left < pos[0] < each.rect.right and each.rect.top < pos[1] < each.rect.bottom):
if each != self.unit_mouse_over:
if self.unit_mouse_over is not None:
self.unit_mouse_over.mouse_out()
self.unit_mouse_over = each
found = True
each.handle(event)
break
if not found:
if self.unit_mouse_over is not None:
self.unit_mouse_over.mouse_out()
self.unit_mouse_over = None
self.board.mainloop.redraw_needed[0] = True
示例4: handle
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handle(self, event):
if event.type == pygame.MOUSEBUTTONDOWN or event.type == pygame.MOUSEBUTTONUP:
self.on_mouse_over()
pos = [event.pos[0] - self.mainloop.sizer.score_bar_pos[0], event.pos[1]]
found = False
for each in self.elements:
if each.rect.topleft[0] + each.rect.width >= pos[0] >= each.rect.topleft[0] and each.rect.topleft[
1] + each.rect.height >= pos[1] >= each.rect.topleft[1]:
found = True
if event.type == pygame.MOUSEBUTTONDOWN:
self.mainloop.mbtndno = each
elif event.type == pygame.MOUSEBUTTONUP and self.mainloop.mbtndno == each:
each.handle(event)
break
if event.type == pygame.MOUSEBUTTONDOWN and not found:
self.mainloop.mbtndno = None
else:
pass
示例5: update
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def update(self, events):
updated = False
for event in events: # type: pygame.event.Event
if event.type == pygame.KEYDOWN and event.key == _controls.KEY_APPLY or \
self.joystick_enabled and event.type == pygame.JOYBUTTONDOWN and event.button == _controls.JOY_BUTTON_SELECT:
self.sound.play_open_menu()
self.apply()
updated = True
elif self.mouse_enabled and event.type == pygame.MOUSEBUTTONUP:
self.sound.play_click_mouse()
if self._rect.collidepoint(*event.pos):
self.apply()
updated = True
return updated
示例6: update
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def update(self, events):
updated = False
for event in events: # type: pygame.event.Event
if self.mouse_enabled and event.type == pygame.MOUSEBUTTONUP:
if self._backbox_rect and self._backbox_rect.collidepoint(*event.pos):
self.sound.play_click_mouse()
self.apply()
updated = True
elif self.joystick_enabled and event.type == pygame.JOYBUTTONDOWN:
if event.button == _controls.JOY_BUTTON_BACK:
self.sound.play_key_del()
self.apply()
updated = True
return updated
示例7: mouse_click
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def mouse_click(x, y, inlist=True, evtype=pygame.MOUSEBUTTONUP):
"""
Generate a mouse click event.
:param x: X coordinate
:type x: int, float
:param y: Y coordinate
:type y: int, float
:param inlist: Return event in a list
:type inlist: bool
:param evtype: event type
:type evtype: int
:return: Event
:rtype: :py:class:`pygame.event.Event`
"""
event_obj = pygame.event.Event(evtype,
{'pos': [float(x), float(y)],
'test': True,
'button': 3
})
if inlist:
event_obj = [event_obj]
return event_obj
示例8: update
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def update(self):
self.keyDownList = []
self.keyUpList = []
self.mouseButtonDown = False
self.mouseButtonUp = False
self.windowResize = False
for event in pygame.event.get(): # checks input events (discrete)
if event.type == pygame.KEYDOWN:
self.keyDownList.append( event.key )
self.keyPressedList.append( event.key )
elif event.type == pygame.KEYUP:
self.keyPressedList.remove( event.key )
self.keyUpList.append( event.key )
elif event.type == pygame.MOUSEBUTTONDOWN:
self.mouseButtonDown = True
self.mouseButtonPressed = True
elif event.type == pygame.MOUSEBUTTONUP:
self.mouseButtonPressed = False
self.mouseButtonUp = True
elif event.type == pygame.QUIT:
self.quitStatus = True
elif event.type == pygame.VIDEORESIZE:
self.windowResize = True
self.windowWidth = event.w
self.windowHeight = event.h
示例9: handleEvent
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handleEvent(self, event, clock):
if not self.visible:
self.focussed = False
return
if self.groups()[0].UI_PLACEMENT_MODE:
if event.type == pygame.MOUSEBUTTONDOWN:
self.pressed_time = pygame.time.get_ticks()
self.focussed = True
if event.type == pygame.MOUSEMOTION:
if (self.focussed and pygame.time.get_ticks() - self.pressed_time > 1000):
self.long_pressed = True
self.rect.top = event.pos[1]
self.rect.left = event.pos[0]
self.dirty = 1
if event.type == pygame.MOUSEBUTTONUP:
if self.focussed and self.long_pressed:
print event.pos[1], event.pos[0]
self.pressed_time = 0
self.long_pressed = False
self.focussed = False
示例10: handleEvents
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def handleEvents(self):
for event in pygame.event.get():
if event.type == pygame.QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE) :
self.webcam.stop()
pygame.quit()
sys.exit()
elif event.type == pygame.MOUSEBUTTONUP:
x,y = pygame.mouse.get_pos()
logger.info('{}, {}'.format(x,y))
if 320<x<800:
if self.canny:
self.canny = False
else:
self.canny = True
示例11: __init__
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def __init__(self):
self.window = Window()
self.window.register_callback(pygame.MOUSEBUTTONUP, self._handle_mouse_up)
self.board = None
self.color = None
self.ally_capture_square = None
self.enemy_capture_square = None
示例12: ProcessMotion
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def ProcessMotion(vf_time):
"""Process pygame events for the window. Mousedown in the target area
starts the simulation. Mouse movement is reported to the 'vf_time' arg
to adjust the current time. Mouseup stop the simulation.
"""
last_pos = None
for event in pygame.event.get():
if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
return sys.exit(0)
if vf_time.IsActive():
if event.type == pygame.MOUSEMOTION:
if event.buttons[0]:
last_pos = event.pos
elif event.type == pygame.MOUSEBUTTONUP:
if event.button == 1:
vf_time.Stop()
else:
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
pos = PixelsToDimensions(event.pos)
x, y = pos
if x > iphone_dims[0] - target_box_width - target_box_padding and \
x < iphone_dims[0] - target_box_padding and \
y > target_box_padding and \
y < iphone_dims[1] - target_box_padding:
vf_time.Start(pos)
if last_pos:
vf_time.AdjustTime(PixelsToDimensions(last_pos))
示例13: ProcessMotion
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def ProcessMotion(active, last_pos):
new_pos = last_pos
for event in pygame.event.get():
if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
return sys.exit(0)
if active:
if event.type == pygame.MOUSEMOTION:
if event.buttons[0]:
new_pos = event.pos
elif event.type == pygame.MOUSEBUTTONUP:
if event.button == 1:
active = False
else:
if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
x_pos, y_pos = [float(pos) / dim for pos, dim in zip(event.pos, window_dimensions)]
if x_pos > (1.0 - target_box_width - target_box_padding) and \
x_pos < (1.0 - target_box_padding) and \
y_pos > target_box_padding and \
y_pos < 1.0 - target_box_padding:
active = True
new_pos = event.pos
x_ratio = EnforceBounds(float(new_pos[0]) / window_dimensions[0], 0.0, 1.0)
old_y_ratio = EnforceBounds(float(last_pos[1]) / window_dimensions[1], 0.0, 1.0)
y_ratio = EnforceBounds(float(new_pos[1]) / window_dimensions[1], 0.0, 1.0)
y_delta = y_ratio - old_y_ratio
return active, new_pos, x_ratio, y_ratio, y_delta
示例14: check
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def check(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
State.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
self.events.append(GUI.LongClickEvent(event))
if event.type == pygame.MOUSEMOTION and len(self.events) > 0 and isinstance(self.events[len(self.events)-1], GUI.LongClickEvent):
self.events[len(self.events)-1].intermediateUpdate(event)
if event.type == pygame.MOUSEBUTTONUP and len(self.events) > 0 and isinstance(self.events[len(self.events)-1], GUI.LongClickEvent):
self.events[len(self.events)-1].end(event)
if not self.events[len(self.events)-1].checkValidLongClick():
self.events[len(self.events)-1] = self.events[len(self.events)-1].mouseUp
示例15: waitforuser
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import MOUSEBUTTONUP [as 别名]
def waitforuser(self):
""" Blocks all events to Main window and wait for user to click OK. """
while self.waiting:
self.redraw()
pygame.display.flip()
for event in pygame.event.get():
pos = pygame.mouse.get_pos()
gpos=GPoint().fromTuple(pos)
if event.type == pygame.MOUSEBUTTONUP:
if self.dragDiff==None:
for ctrl in self.controls:
ctrl.handleMouseUp(pos,event.button)
else: # handle window move
self.dragDiff=None
if event.type == pygame.MOUSEBUTTONDOWN:
if gpos.inGRect(self.titlerect):
self.dragDiff = gpos - self.winrect.p1
else:
for ctrl in self.controls:
ctrl.handleMouseDown(pos,event.button)
if event.type == pygame.MOUSEMOTION:
if not self.dragDiff==None:
self.winrect.p1=gpos-self.dragDiff
self.reposControls()
else:
for ctrl in self.controls:
ctrl.handleMouseMove(pos)
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
print("Escape key pressed down.")
self.waiting = False