Skip to content

Commit 10ffb10

Browse files
committed
retag0.3.0
2 parents 2053064 + 893fc1f commit 10ffb10

File tree

8 files changed

+62
-63
lines changed

8 files changed

+62
-63
lines changed

cocos/cocosnode.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def inner(self, value):
160160
setattr(self, "transform_"+attr,value)
161161
return inner
162162
def get_attr():
163-
def inner(self, value):
163+
def inner(self):
164164
if getattr(self,"children_"+attr) != getattr(self, "transform_"+attr):
165165
raise Exception("no consistent value for "+attr)
166166
return getattr(self,"children_"+attr)
@@ -292,10 +292,6 @@ def unschedule(self, callback):
292292
self.scheduled_interval_calls = [
293293
c for c in self.scheduled_interval_calls if c[0] != callback
294294
]
295-
if total_len == len(
296-
self.scheduled_calls + self.scheduled_interval_calls
297-
):
298-
raise Exception("Call not scheduled")
299295

300296
if self.is_running:
301297
pyglet.clock.unschedule( callback )

cocos/framegrabber.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# * Redistributions of source code must retain the above copyright
1010
# notice, this list of conditions and the following disclaimer.
11-
# * Redistributions in binary form must reproduce the above copyright
11+
# * Redistributions in binary form must reproduce the above copyright
1212
# notice, this list of conditions and the following disclaimer in
1313
# the documentation and/or other materials provided with the
1414
# distribution.
@@ -62,7 +62,8 @@ def TextureGrabber():
6262
_best_grabber = FBOGrabber
6363
return _best_grabber()
6464
except:
65-
pass
65+
import traceback
66+
traceback.print_exc()
6667
# Fallback: GL generic grabber
6768
raise Exception("ERROR: GPU doesn't support Frame Buffers Objects. Can't continue")
6869
# _best_grabber = GenericGrabber
@@ -74,20 +75,20 @@ class GenericGrabber(object):
7475
implementation."""
7576
def grab (self, texture):
7677
pass
77-
78+
7879
def before_render (self, texture):
7980
director.window.clear()
80-
81+
8182
def after_render (self, texture):
8283
buffer = image.get_buffer_manager().get_color_buffer()
8384
texture.blit_into(buffer, 0, 0, 0)
8485

8586
class PbufferGrabber(object):
8687
"""A render-to texture mechanism using pbuffers.
8788
Requires pbuffer extensions. Currently only implemented in GLX.
88-
89+
8990
Not working yet, very untested
90-
91+
9192
TODO: finish pbuffer grabber
9293
"""
9394
def grab (self, texture):
@@ -99,7 +100,7 @@ def grab (self, texture):
99100
GLX_DEPTH_SIZE, 24,
100101
GLX_DOUBLEBUFFER, 1,
101102
])
102-
103+
103104
def before_render (self, texture):
104105
self.pbuf.switch_to()
105106
gl.glViewport(0, 0, self.pbuf.width, self.pbuf.height)
@@ -108,7 +109,7 @@ def before_render (self, texture):
108109
gl.glOrtho(0, self.pbuf.width, 0, self.pbuf.height, -1, 1)
109110
gl.glMatrixMode(gl.GL_MODELVIEW)
110111
gl.glEnable (gl.GL_TEXTURE_2D)
111-
112+
112113
def after_render (self, texture):
113114
buffer = image.get_buffer_manager().get_color_buffer()
114115
texture.blit_into (buffer, 0, 0, 0)
@@ -131,10 +132,10 @@ def grab (self, texture):
131132
self.fbuf.texture2d (texture)
132133
self.fbuf.check_status()
133134
self.fbuf.unbind()
134-
135+
135136
def before_render (self, texture):
136137
self.fbuf.bind()
137138
glClear(GL_COLOR_BUFFER_BIT)
138-
139+
139140
def after_render (self, texture):
140141
self.fbuf.unbind()

cocos/gl_framebuffer_object.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#
99
# * Redistributions of source code must retain the above copyright
1010
# notice, this list of conditions and the following disclaimer.
11-
# * Redistributions in binary form must reproduce the above copyright
11+
# * Redistributions in binary form must reproduce the above copyright
1212
# notice, this list of conditions and the following disclaimer in
1313
# the documentation and/or other materials provided with the
1414
# distribution.
@@ -41,14 +41,14 @@
4141
class FramebufferObject (object):
4242
"""
4343
Wrapper for framebuffer objects. See
44-
44+
4545
http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt
46-
46+
4747
API is not very OO, should be improved.
4848
"""
4949
def __init__ (self):
5050
"""Create a new framebuffer object"""
51-
id = c_ulong(0)
51+
id = c_uint(0)
5252
glGenFramebuffersEXT (1, byref(id))
5353
self._id = id.value
5454

cocos/tiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def load(filename, paths=None):
323323
unicode=unicode,
324324
int=int,
325325
float=float,
326-
bool=bool,
326+
bool=lambda value: value != "False",
327327
)
328328
_python_to_xml = {
329329
str: unicode,

doc/programming_guide/quickstart.txt

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ Always call ``super`` in the constructor::
3535
To display the text, we'll create a `Label`. Keyword arguments are used
3636
to set the font, position and alignment of the label::
3737

38-
label = cocos.text.Label('Hello, world',
39-
font_name='Times New Roman',
40-
font_size=36,
41-
halign='center', valign='center')
38+
label = cocos.text.Label('Hello, world',
39+
font_name='Times New Roman',
40+
font_size=32,
41+
anchor_x='center', anchor_y='center')
4242

4343
The label position will be the center of the screen::
4444

4545
label.position = 320,240
46-
46+
4747
Since `Label` is a subclass of `CocosNode` it can be added
4848
as a child. All `CocosNode` objects know how to render itself, perform actions
4949
and transformations.
5050
To add it as a layer's child, use the `CocosNode.add` method::
51-
51+
5252
self.add( label )
5353

5454
After defining the ``HelloWorld`` class, we need to initialize and create a window.
@@ -80,7 +80,7 @@ Hello Actions
8080

8181
This example is very similar to example #1, with the difference that it introduces
8282
us to the world of actions.
83-
An action is like an order. You can tell **any** `CocosNode` object to execute an
83+
An action is like an order. You can tell **any** `CocosNode` object to execute an
8484
action.
8585
You can find the entire program in the `samples/hello_world_actions.py` file.
8686

@@ -89,12 +89,12 @@ Like in our previous example, we import the cocos package::
8989

9090
import cocos
9191

92-
If you're going to use several actions, you can import all
92+
If you're going to use several actions, you can import all
9393
the available actions into the namespace with this import::
9494

9595
from cocos.actions import *
9696

97-
We subclass `ColorLayer` to have a background color, and then
97+
We subclass `ColorLayer` to have a background color, and then
9898
we call super() with a blueish color::
9999

100100
class HelloWorld(cocos.layer.ColorLayer):
@@ -115,16 +115,16 @@ As in the previous example, we create and add a label::
115115

116116
In this example we also create and add an sprite as a child. In cocos2d
117117
sprites are `Sprite` objects::
118-
118+
119119
sprite = cocos.sprite.Sprite('grossini.png')
120120

121121
We place the sprite in the center of the screen. Default position is (0,0)::
122-
122+
123123
sprite.position = 320,240
124124

125125
We set the scale attribute to 3. This means that our sprite will be 3 times bigger.
126126
The default scale attribute is 1::
127-
127+
128128
sprite.scale = 3
129129

130130
We add the sprite as a child but on top of the label by setting the z-value to 1, since
@@ -142,15 +142,15 @@ We tell the label to:
142142
3. and we repeat these 2 actions forever
143143

144144
Notice that the '+' operator is the `Sequence` action::
145-
145+
146146
label.do( Repeat( scale + Reverse( scale) ) )
147147

148148
And we tell the sprite to do the same actions but starting with the 'scale back' action::
149-
149+
150150
sprite.do( Repeat( Reverse(scale) + scale ) )
151151

152152
Then we initialize the director, like in the previous example::
153-
153+
154154
cocos.director.director.init()
155155
hello_layer = HelloWorld ()
156156

@@ -184,18 +184,18 @@ This demo has a scene with two layers; one shows which keys are currently presse
184184
We start defining the KeyDisplay layer class. As always, we put some initialization on ``__init__`` and the code for displaying it in step::
185185

186186
class KeyDisplay(cocos.layer.Layer):
187-
187+
188188
# If you want that your layer receives events
189189
# you must set this variable to 'True',
190190
# otherwise it won't receive any event.
191191
is_event_handler = True
192-
192+
193193
def __init__(self):
194-
194+
195195
super( KeyDisplay, self ).__init__()
196-
196+
197197
self.text = cocos.text.Label("", x=100, y=280 )
198-
198+
199199
# To keep track of which keys are pressed:
200200
self.keys_pressed = set()
201201
self.update_text()
@@ -215,23 +215,23 @@ This class defines a key_pressed set, which should be the set of keys pressed at
215215
'modifiers' is a bitwise or of several constants indicating which
216216
modifiers are active at the time of the press (ctrl, shift, capslock, etc.)
217217
"""
218-
218+
219219
self.keys_pressed.add (key)
220220
self.update_text()
221-
221+
222222
def on_key_release (self, key, modifiers):
223223
"""This function is called when a key is released.
224-
224+
225225
'key' is a constant indicating which key was pressed.
226226
'modifiers' is a bitwise or of several constants indicating which
227227
modifiers are active at the time of the press (ctrl, shift, capslock, etc.)
228-
228+
229229
Constants are the ones from pyglet.window.key
230230
"""
231-
231+
232232
self.keys_pressed.remove (key)
233233
self.update_text()
234-
234+
235235
def update_text(self):
236236
key_names = [pyglet.window.key.symbol_string (k) for k in self.keys_pressed]
237237
text = 'Keys: '+','.join (key_names)
@@ -243,12 +243,12 @@ With that code, the layer is now fully working. You can press and release keys o
243243
Handling mouse input is similar. You have three events of interest: on_mouse_press, on_mouse_release and on_mouse_motion. With that, we can define our layer::
244244

245245
class MouseDisplay(cocos.layer.Layer):
246-
246+
247247
is_event_handler = True #: enable pyglet's events
248-
248+
249249
def __init__(self):
250250
super( MouseDisplay, self ).__init__()
251-
251+
252252
self.posx = 100
253253
self.posy = 240
254254
self.text = cocos.text.Label('No mouse events yet', font_size=18, x=self.posx, y=self.posy )
@@ -264,16 +264,16 @@ And then add event handlers to update the text when the mouse is moved, and chan
264264

265265
def on_mouse_motion (self, x, y, dx, dy):
266266
"""This function is called when the mouse is moved over the app.
267-
267+
268268
(x, y) are the physical coordinates of the mouse
269269
(dx, dy) is the distance vector covered by the mouse pointer since the
270270
last call.
271271
"""
272272
self.update_text (x, y)
273-
273+
274274
def on_mouse_press (self, x, y, buttons, modifiers):
275275
"""This function is called when any mouse button is pressed
276-
276+
277277
(x, y) are the physical coordinates of the mouse
278278
'buttons' is a bitwise or of pyglet.window.mouse constants LEFT, MIDDLE, RIGHT
279279
'modifiers' is a bitwise or of pyglet.window.key modifier constants
@@ -295,7 +295,7 @@ You can now play to the demo and change it. Some things you can try are:
295295
* Change the on_mouse_press handler and remove the mapping to virtual coordinates; note how it behaves strangely after resizing the window
296296
* Note that the mouse coordinates on screen are physical coordinates, so their range changes when resizing the window; modify the demo to show virtual coordinates.
297297
* Change the code to be able to move the mouse coordinates label when you drag the mouse (hint: a mouse drag is a sequence of button_press, several motions, and a button_release event)
298-
* Change the code so the keyboard display also shows the modifiers set at each time
298+
* Change the code so the keyboard display also shows the modifiers set at each time
299299

300300
Where to next?
301301
--------------
@@ -311,11 +311,11 @@ the entire guide from start to finish.
311311

312312
To achieve optimal performance in your 2D
313313
applications you'll need to work with OpenGL directly. The canonical
314-
references for OpenGL are `The OpenGL Programming Guide`_ and
314+
references for OpenGL are `The OpenGL Programming Guide`_ and
315315
`The OpenGL Shading Language`_.
316316

317-
Since cocos2d uses pyglet you shall also check `pyglet Programming Guide`_
318-
and `pyglet API Reference`_
317+
Since cocos2d uses pyglet you shall also check `pyglet Programming Guide`_
318+
and `pyglet API Reference`_
319319

320320
There are numerous examples of cocos2d applications in the ``samples/``
321321
directory of the documentation and source distributions. Keep checking

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
[egg_info]
2-
tag_build = beta
32
tag_date = 0
43
tag_svn_revision = 0

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
__author__ = "cocos2d team"
10-
__version__ = "0.3.0-rc0"
10+
__version__ = "0.3.0"
1111
__date__ = "2008-06-27"
1212

1313
try:
@@ -31,6 +31,7 @@
3131
* Creating transitions between scenes
3232
* Managing sprites
3333
* Basic menus
34+
* and much more!
3435
"""
3536

3637
setup(
@@ -42,7 +43,7 @@
4243

4344
packages = find_packages(),
4445

45-
install_requires=['pyglet>=1.1beta1',],
46+
install_requires=['pyglet>=1.1.1',],
4647
dependency_links=['http://code.google.com/p/pyglet/downloads/list',],
4748

4849
include_package_data = True,

test/test_sprite.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
class TestLayer(cocos.layer.Layer):
1414
def __init__(self):
1515
super( TestLayer, self ).__init__()
16-
16+
1717
x,y = director.get_window_size()
18-
18+
1919
self.sprite = Sprite('grossini.png')
2020
self.sprite.position = x/2, y/2
2121
self.add( self.sprite )
22-
23-
22+
x = self.sprite.anchor
23+
self.sprite.anchor = x
24+
25+
2426

2527
if __name__ == "__main__":
2628
director.init()

0 commit comments

Comments
 (0)