当前位置: 首页>>代码示例>>Python>>正文


Python Scatter.on_touch_down方法代码示例

本文整理汇总了Python中kivy.uix.scatter.Scatter.on_touch_down方法的典型用法代码示例。如果您正苦于以下问题:Python Scatter.on_touch_down方法的具体用法?Python Scatter.on_touch_down怎么用?Python Scatter.on_touch_down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.uix.scatter.Scatter的用法示例。


在下文中一共展示了Scatter.on_touch_down方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_touch_down

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]
	def on_touch_down (self, touch):
		if not 'markerid' in touch.profile:
			return
		hand_id = int(touch.fid / self.hand_gesture_offset)
		gesture_id = touch.fid % self.hand_gesture_offset
		if not self.object_moving and gesture_id == self.grab_gesture:
			self.canvas.clear()
			self.draw()
			self.canvas.add(Ellipse(pos=(touch.x-self.x, touch.y-self.y), size=(30,30)))
			"""
			"  grab  "
			"""
			if self.my_object.collide_point(touch.x-self.x, touch.y-self.y):
				self.play_grab_sound()
				# does not seem necessary
				# self.my_object.dispatch('on_touch_down', touch)
				self.object_moving = True
				self.my_object.owner_id = hand_id
				self.object_grabbed_event()
				return True

		# keeps x-location of touch, to use for sliding the workspace later
		"""
		"  sense sliding  "
		"""
		if self.object_moving and hand_id != self.my_object.owner_id:
			touch.ud['initial'] = touch.x
			print 'started sliding'

		# calls same function in it's ancestor
		Scatter.on_touch_down(self, touch)
开发者ID:arasbm,项目名称:NTExperiment,代码行数:33,代码来源:neartouch.py

示例2: on_touch_down

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]
    def on_touch_down(self, touch):
        """
        Defines actions to perform when the criterion is touched up
        :param touch: the touch point (position, type of touch, ...)
        """
        if not self.destroyed:
            if self.collide_point(touch.x, touch.y):
                Scatter.on_touch_down(self, touch)

                if touch.is_double_tap and self.support != "tablette":
                    if self.zoom_mode:
                        self.size = (120,120)
                        self.zoom_mode = False
                    else:
                        self.size = (400, 400)
                        self.zoom_mode = True
                    self.remove_widget(self.label_question)
                    self.remove_widget(self.label_text)
                    self.label_text_pos = [5, 5 + self.size[1] / 5]
                    self.label_text_size = [self.size[0] - 10, self.size[1] - 30 - 2 * self.size[1] / 5]
                    self.label_question_pos = [5, self.size[1] - self.size[1] / 5 - 25]
                    self.label_question_size = [self.size[0] - 10, 20]

                    self.label_question = Label(text=self.text_type, text_size=self.label_question_size,
                                                pos=self.label_question_pos, halign="left", valign='top',
                                                size=self.label_question_size)
                    self.label_text = Label(text=self.text, text_size=self.label_text_size, pos=self.label_text_pos,
                                            valign='top', halign="left", size_hint_y=None, multiline=True,
                                            size=self.label_text_size)
                    self.add_widget(self.label_question)
                    self.add_widget(self.label_text)
开发者ID:lachand,项目名称:StageIndicateursMultiDispositifs,代码行数:33,代码来源:Critere.py

示例3: on_touch_down

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]
 def on_touch_down(self, touch):
     button = getattr(touch, 'button', -1)
     if self.manager.activated and button == "left":
         if self.collide_point(*touch.pos):
             self.manager.current_screen = self.wrapped
             self.manager.activated = False #trigger the othrs tuff
             return True
     return Scatter.on_touch_down(self, touch)
开发者ID:opqopq,项目名称:BoardGameMaker,代码行数:10,代码来源:virtual_screen.py

示例4: on_touch_down

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]
	def on_touch_down (self, touch):
		# if object touched call it's on_touch_down function and disable panning workspaces
		# by returning True

		"""
		"  grab  "
		"""
		if self.my_object != None and self.my_object.collide_point(touch.x-self.x, touch.y-self.y):
			self.my_object.dispatch('on_touch_down', touch)
			# TODO maybe keep touch itself in my_object, instead of it's ud
			self.object_moving = True
			self.my_object.owner_id = touch.uid
			self.play_grab_sound()
			self.object_grabbed_event()
			return True
		# calls same function in it's ancestor
		# keeps x-location of touch, to use for sliding the workspace later
		Scatter.on_touch_down(self, touch)
		"""
		"  sense sliding  "
		"""
		touch.ud['initial'] = touch.x
开发者ID:arasbm,项目名称:NTExperiment,代码行数:24,代码来源:multitouch.py

示例5: on_touch_down

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]
 def on_touch_down(self, touch):
     if not self.collide_point(touch.x, touch.y):
         return
     self.touches.add(touch.uid)
     if not self.selected:
         self.selected= True
     
     if touch.is_double_tap:
         self.full=True
         self.center_animation.start(self)            
         return True
     self.back_animation.stop(self)
     return Scatter.on_touch_down(self, touch)
开发者ID:ArpegiusWhooves,项目名称:KivyPicturesExampleTest,代码行数:15,代码来源:main.py

示例6: DeckWidget

# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_down [as 别名]

#.........这里部分代码省略.........
                self.deck.next(self.deck.mode)
                self.update_selected_text()
                self.card_base.center_x = self.card_center[0] * 2.5
                ret_to_center.bind(on_complete=toggle_is_playing)
                ret_to_center.start(self.card_base)

            y.bind(on_complete=begin_entrance_y)
            y.start(self.card_base)

    def on_touch_up(self, touch):
        """
        Goals:
            -If the card is touch-released very close (<5px) to the original position, it should play a flip animation.
            -When the card is released a bit further, it should transition back to the original position.
            -If the card is released at a point where half of it's face is offscreen, the card should
                transition off screen and another card should transition on screen.
        All of this should not be able to happen again if any animation is already playing.
        """
        if not self.deck.is_empty():
            if (
                self.card_base.center[0] < self.card_center[0] + 5
                and self.card_base.center[0] > self.card_center[0] - 5
            ):
                # Do flip animation
                if not self.cardflip_animations["is_playing"] and self.cardflip_animations["down_success"]:
                    self.cardflip_animations["is_playing"] = True
                    self.flip_animation()
            elif self.card_base.center[0] > (self.card_center[0] * 1.65):
                # Do offscreen/onscreen transition rightwards
                if not self.offscreen_animations["is_playing"]:
                    self.offscreen_animations["is_playing"] = True
                    self.offscreen_animation(True)
            elif self.card_base.center[0] < (self.card_center[0] * 0.35):
                # Do offscreen/onscreen transition leftwards
                if self.deck.mode != None:
                    self.card_snapback_animation.start(self.card_base)
                elif not self.offscreen_animations["is_playing"]:
                    self.offscreen_animations["is_playing"] = True
                    self.offscreen_animation(False)
            else:
                # Do transition-to-origin animation
                self.card_snapback_animation.start(self.card_base)

            # Swipe Emulation - See DeckWidget.on_touch_move()
            if self.touch_move_counter < 7 and self.touch_move_counter > 1:
                x_difference = self.touch_move_current[0] - self.touch_move_init[0]
                y_difference = self.touch_move_current[1] - self.touch_move_init[1]
                if x_difference > 5 and x_difference > y_difference:
                    if not self.offscreen_animations["is_playing"] and not self.cardflip_animations["is_playing"]:
                        self.offscreen_animations["is_playing"] = True
                        self.offscreen_animation(True)
                elif x_difference < -5 and x_difference < y_difference:
                    if not self.offscreen_animations["is_playing"] and not self.cardflip_animations["is_playing"]:
                        self.offscreen_animations["is_playing"] = True
                        self.offscreen_animation(False)
            self.touch_move_counter = 0

    def on_touch_move(self, touch):
        """
            At the last minute, I noticed how my launcher on my android phone behaves when you swap
            the screens. Even if your finger doesn't cover a significant distance. If you swipe quickly
            with a clear direction yet very short distance, the screen will change.
            
            It's only when you move your finger slowly with a short distances will the screen bounce back to 
            the original position. I wanted to try emulating this to an extent; swiping fast should play
            the offscreen animations while swiping slow would cause the snapback animation effect.
            
            Also, the swipe must be bigger in the x-direction than it is in the y-direction.
        """
        if not self.deck.is_empty():
            if self.touch_move_counter == 0:
                self.touch_move_init = touch.pos
            else:
                self.touch_move_current = touch.pos
            self.touch_move_counter += 1

    def on_touch_down(self, touch):
        """
            Dictates what happens when the DeckWidget is clicked/touched but not released yet. 
            Scatter.on_touch_down() handles sliding (card_base is a Scatter). Also, I only want
            this to work if no animations are playing. 
        """
        if not self.deck.is_empty():
            if self.offscreen_animations["is_playing"] == False and self.cardflip_animations["is_playing"] == False:
                self.card_base.on_touch_down(touch)
                self.cardflip_animations["down_success"] = True
            else:
                self.cardflip_animations["down_success"] = False

            if not self.cardflip_animations["is_playing"]:
                self.remove_widget(self.widgets["card_text"])
                self.widgets["card_text"] = Label(
                    center=self.card_base.center,
                    size=(20, 20),
                    font_size=sp(15),
                    text=self.text_content,
                    color=[0, 0, 0, 1],
                )
                self.add_widget(self.widgets["card_text"])
                self.widgets["card_text"].center = self.card_base.center
开发者ID:kockiya,项目名称:Flashcards,代码行数:104,代码来源:deckwidget.py


注:本文中的kivy.uix.scatter.Scatter.on_touch_down方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。