forked from los-cocos/cocos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_handler.py
More file actions
35 lines (28 loc) · 890 Bytes
/
test_handler.py
File metadata and controls
35 lines (28 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import division, print_function, unicode_literals
# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
#
testinfo = "s, q"
tags = "is_event_handler, on_key_press"
import cocos
from cocos.director import director
from cocos.sprite import Sprite
import pyglet
class PrintKey(cocos.layer.Layer):
is_event_handler = True
def on_key_press (self, key, modifiers):
print("Key Pressed:", key, modifiers)
description = """
When pressing keys the key with modifiers should print on console
"""
def main():
print(description)
director.init()
bg_layer = cocos.layer.ColorLayer(255,0,0,255)
test_layer = PrintKey()
main_scene = cocos.scene.Scene (bg_layer, test_layer)
director.run (main_scene)
if __name__ == '__main__':
main()