On Tue, Feb 25, 2014 at 12:36 PM, Mikko Finell <[email protected]>wrote:

> That does sound better than what I was going to try: To load all the
> sequences as pyglet animation objects and somehow add / remove them from a
> batch (just let play whatever frame is on.)
>
>
>
>         - _update_animation(dt) -> advances animation time, calc if a new
>> image is needed, if so update the actor image
>>
> Who is calling this? Do you mean something like
> Layer.schedule(actor.update)
>
> and
>
> def update(dt):
>     duration += dt
>     if duration == frame_rate:
>         self.advance_animation(sequence.next())
>
>
>
>
Who calls: usually you have something in the line

def update(self, dt):
    self.update_physics(dt)
    self.update_AI(dt)
    self._update_anim(dt)

In _update_anim I will not assume a fixed duration for each frame, so more
like

http://pastebin.com/4ZKiEP6b
The anim related state used by _update_anim should be initialized by
start_anim


>
>>     - Have an adequate data structure to hold the animation description,
>> usually a dict with sequence name as key ( 'idle', 'walk_left', etc ) and
>> a
>> list of tuples with ( frame_duration, frame_info ).
>>       frame_info at least needs to specify which image is needed, but may
>> have extra info like dimensions of collision rect.
>>       A minimal data example may look as
>>       anim_data = {
>>          'idle': [(0, 'player_idle'), ],
>>          'walk_left': [(0.1, 'walk_left_1'), (0.1, 'walk_left_2'), ...],
>>          ...
>>       }
>>
> How is the sprite ultimately produced in cocos?


a gl texture
texture coords for the corners


> If I understand what you mean, the 'walk_x' will maybe be textures from a
> pyglet texture grid.
>
> Something like
>
> def advance_frame(texture):
>     self.batch.remove(previous)
>     self.batch.add(texture)
>
>
No, that's too costly

Texture(s) are added only once; two ways to do the changes:
   - Easier to write, but inefficient, have a texture for each frame, if
Actor inherits from Sprite the change needed is self.image =
self.current_anim_image

   - Faster: all images in one texture, a frame change changes the texture
coords ( a search for atlas or spritesheet in pyglet list can give useful
results)


> I don't think I've understood (and I haven't tested anything yet) but this
> does not seem very smooth. Would you please elaborate on these questions a
> bit more? All I know is that the sprites must exist in a batch when they
> are shown, or else the cocos app quickly suffers reduced frame rate.
>
>
Hope this helps.

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to