After reading those threads, I tried another way to "cut" a sprite (ie only 
display some part of it) :
https://groups.google.com/forum/?fromgroups#!topic/cocos-discuss/Ks83VdBj9Wk%5B1-25%5D
 
https://groups.google.com/forum/?fromgroups#!topic/cocos-discuss/vUZOwNZW_GY%5B1-25%5D
 

Here's what I came up with for cutting the top of a sprite (the only thing 
I'm actually interested in) :

class Cut_Sprite(cocos.sprite.Sprite):
    
    def __init__(self,*args,**kwargs):
        super(Cut_Sprite,self).__init__(*args,**kwargs)
        self.tex_scale = self.width/self._vertex_list.tex_coords[3] #used 
to convert pixels to texture coords
        
    def cut(self,desired_height):
        desired_height=int(desired_height)#needs int
        self._vertex_list.vertices[5]=self.y+desired_height
        self._vertex_list.vertices[7]=self.y+desired_height
        self._vertex_list.tex_coords[7]=desired_height/self.tex_scale
        self._vertex_list.tex_coords[10]=desired_height/self.tex_scale

What do you think of such a solution ? I'm a newbie, I don't know anything 
about openGL, so I guess there are other/better solutions (some are 
mentionned in the threads I mentionned earlier), but this one works both 
inside and outside a batch.
here's a small test-app : http://pastebin.com/xmn0KERe

-- 
You received this message because you are subscribed to the Google Groups 
"cocos2d discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/cocos-discuss/-/odPUriqZKcEJ.
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