wel, here is code, as i said just trying to merge code above with
test_sprite from cocos...probably making very stupid mistake here, but
don't really understand...

# 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__), '..'))
#


import cocos
from cocos.director import director
from cocos.sprite import Sprite
import pyglet
import squirtle

class SVGNode(cocos.cocosnode.CocosNode):
    """ A CocosNode that displays an SVG image, using squirtle library
"""
    def __init__(self, filename):
        super(SVGNode, self).__init__()
        file = pyglet.resource.file(filename)
        self.image = squirtle.SVG(file = file, anchor_x = "center",
anchor_y = "center")
        self.width, self.height = self.image.width, self.image.height
    def draw(self):
        glPushMatrix()
        glEnable(GL_POINT_SMOOTH)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
        (x, y), angle, scale = self.position, self.rotation,self.scale
        self.image.draw(x = x, y = y, angle = angle, scale = scale)
        glPopMatrix()
class SVGSprite(cocos.sprite.Sprite):
    """ A subclass of cocos Sprite that will accept the name of an SVG
image """
    def __init__(self, filename):
        node = SVGNode(filename)
        image = pyglet.image.create(width = int(node.width), height =
int(node.height))
        cocos.sprite.Sprite.__init__(self, image)
        self.add(node)

class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = SVGSprite('elements.svg')
        self.sprite.position = x/2, y/2
        self.add( self.sprite  )
        x = self.sprite.anchor
        self.sprite.anchor = x



if __name__ == "__main__":
    director.init()
    test_layer = TestLayer ()
    squirtle.setup_gl()
    main_scene = cocos.scene.Scene (test_layer)
    director.run (main_scene)

python saying:

Traceback (most recent call last):
  File "/Users/sonomute/workin_bin/python/squirtle-0.2.4/
test_sprite_svg.py", line 57, in <module>
    test_layer = TestLayer ()
  File "/Users/sonomute/workin_bin/python/squirtle-0.2.4/
test_sprite_svg.py", line 47, in __init__
    self.sprite = SVGSprite('elements.svg')
  File "/Users/sonomute/workin_bin/python/squirtle-0.2.4/
test_sprite_svg.py", line 35, in __init__
    node = SVGNode(filename)
  File "/Users/sonomute/workin_bin/python/squirtle-0.2.4/
test_sprite_svg.py", line 21, in __init__
    anchor_y = "center")
TypeError: __init__() got an unexpected keyword argument 'file'


Thank you!

On Mar 5, 1:44 am, Lucio Torre <[email protected]> wrote:
> On Wed, Mar 4, 2009 at 9:14 PM, sonomute <[email protected]> wrote:
>
> > I'm really sorry for being so stupid, but can somebody explain to me
> > how to use that code above?
>
> > I was trying to merge it with the simple code from cocos2d /test
> > folder, sprite_test.py(or test_sprite.py?) but python always telling
> > me about syntax errors...
>
> > It will be nice to have real example...i'm from musical background, no
> > programming before(only PD and MAX/MSP)...
>
> its easier to solve problems if you paste a traceback and code.
>
> also, for python questions you will find more people that can help at
> python-list.
>
> regards,
> Lucio.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to