Mercurial > touhou
comparison pytouhou/game/text.py @ 322:4e8192aadcaa
Give a better interface for text handling.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Thu, 24 May 2012 20:23:57 +0200 |
parents | f3099ebf4f61 |
children | 2fcdb8966957 |
comparison
equal
deleted
inserted
replaced
321:61adb5453e46 | 322:4e8192aadcaa |
---|---|
25 | 25 |
26 self.x, self.y = pos | 26 self.x, self.y = pos |
27 | 27 |
28 | 28 |
29 class Text(object): | 29 class Text(object): |
30 def __init__(self, pos, text, front_wrapper, ascii_wrapper): | 30 def __init__(self, pos, ascii_wrapper=None, front_wrapper=None, text=''): |
31 self.sprite = Sprite() | 31 self.sprite = Sprite() |
32 self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite) | |
33 self.anmrunner.run_frame() | |
34 self.removed = False | 32 self.removed = False |
35 self.changed = True | 33 self.changed = True |
36 | 34 |
37 self.text = '' | 35 self.text = '' |
38 self.glyphes = [] | 36 self.glyphes = [] |
39 | 37 |
40 self.front_wrapper = front_wrapper | 38 self.front_wrapper = front_wrapper |
41 self.ascii_wrapper = ascii_wrapper | 39 self.ascii_wrapper = ascii_wrapper |
42 | 40 |
41 if front_wrapper: | |
42 self.anmrunner = ANMRunner(front_wrapper, 22, self.sprite) | |
43 self.anmrunner.run_frame() | |
44 | |
43 self.x, self.y = pos | 45 self.x, self.y = pos |
44 self.set_text(text) | 46 self.set_text(text) |
45 | 47 |
46 | 48 |
47 def objects(self): | 49 def objects(self): |
48 return self.glyphes + [self] | 50 return self.glyphes + ([self] if self.front_wrapper else []) |
49 | 51 |
50 | 52 |
51 def set_text(self, text): | 53 def set_text(self, text): |
52 if text == self.text: | 54 if text == self.text: |
53 return | 55 return |