I tried to implement a motion blur using layer and putting all blurs
on it. But it seems veeery slow. FPS drops 20-30 on my old PC.

----------------------------------
class BoxBlur(Layer):
        "Box guy  motion blur"

        def __init__(self, box):
            Layer.__init__(self)
            self.box = box
            #self.anchor = self.box.anchor
            self.active = False
            self.moveBlur = False
            self.boostBlur = False

        def update(self,dt):
            self.active = True if self.box.velocityVec.tuple() !=
box2d.b2Vec2_zero.tuple() else False
            #print pyglet.clock._default._schedule_interval_items
            if self.active:
                if self.box.boosting:
                    if self.moveBlur:
                        self.unschedule(self.addMoveBlur)
                        self.moveBlur = False
                    if not self.moveBlur:
                        self.schedule_interval(self.addMoveBlur,
1/500.)
                        self.moveBlur = True

            elif not self.active:
                self.moveBlur = False
                self.unschedule(self.addMoveBlur)

        def addMoveBlur(self,dt):

            blur = Sprite(Images.box,opacity=200)
            blur._group = pyglet.sprite.SpriteGroup(blur._texture,
GL_SRC_ALPHA, GL_ONE, None)
            blur._create_vertex_list()
            blur.position = self.box.position
            blur.rotation = self.box.rotation
            blur.color = self.box.moveColor
            blur.scale=self.box.scale
            self.add(blur)

            blur.do(FadeOut(1.0) + self.RemoveBlur())

        class RemoveBlur( InstantAction ):
            def init(self):
                pass
            def start(self):
                self.target.parent.remove(self.target)

----------------------------------

I found other solution, but don't know how to do it. Hep please.
1. Optimize exisiting Layer-based code. Lotsa Python calls makes it
very slow i guess.
2. Use ParticleSystem emitting particles (blurs) that stays in place
just after emitted while the ParticleSystem moves together with the
playersprite.
3. Use code from cocos2d-iphone StreakMotion test (experimental) (?)
--~--~---------~--~----~------------~-------~--~----~
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