Book Image

Kivy - Interactive Applications and Games in Python

By : Roberto Ulloa
Book Image

Kivy - Interactive Applications and Games in Python

By: Roberto Ulloa

Overview of this book

Table of Contents (13 chapters)
Kivy – Interactive Applications and Games in Python Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Scatter – multi-touching to drag, rotate, and scale


In the previous chapter (Chapter 3, Widget Events – Binding Actions), you learned how to use events to drag widgets. You learned how to use the on_touch_up, on_touch_move, and on_touch_down events. However, the Scatter class already provides that functionality and also lets us scale and rotate using two fingers, as one would on a mobile or tablet screen. All the functionality is included inside the Scatter class; however, we need to apply a few changes to keep our project consistent. In particular, we still want our group mode to work, so that translating, scaling, and rotating can happen at the same time. Let us implement the changes in four big steps in the comicwidgets.py file:

  1. Replace the DraggableWidget base class. Let's use Scatter instead of RelativeLayout (line 132 and 135):

    131. # File name: comicwidgets.py
    132. from kivy.uix.scatter import Scatter
    133. from kivy.graphics import Line
    134. 
    135. class DraggableWidget(Scatter):

    Note...