On Monday, April 9, 2012 11:58:51 AM UTC-5, Claudio Canepa wrote:
>
>
>
> On Mon, Apr 9, 2012 at 12:38 PM, Oninoshiko <[email protected]> wrote:
>
>>
>>
>> Of course! What I have is this:
>>
>>  class ReplaceScene(InstantAction):
>>     def init(self, newscene):
>>         self.newscene = newscene
>>
>>     def start(self):
>>         director.replace(self.newscene)
>>
>>  Ideally, I just want to be able to add "ReplaceAction(Scene(layer))" to 
>> the end of a Action sequence.
>> -- 
>>
>
> I see.
> A clean way to obtain an action with this behavior is this:
>
> def get_action_replace_scene(scene):
>       def changer():
>           director.replace(scene)
>
>       template_action = ac.CallFunc(changer)
>       return template_action
>
> and you use like
>
> template_action = ac.Delay(1.0) + get_action_replace_scene(scene2)
> scene1.do(template_action)
> director.run(scene1)
> See test demo for this in http://pastebin.com/xVW3WYJW
>
>
> claudio
>
> --
>
>
That worked great. Here is what I ended up with, all three seem to work 
fine. If this is something that would be desired in a later release, feel 
free to use this with me blessing! 

-- 
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/-/wM78OATEZVIJ.
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.

#
# SceneAction.py
#
#
from cocos.actions import InstantAction, CallFunc
from cocos.director import director

# Pop the Scene
class PopScene(InstantAction):
	def start(self):
		director.pop()

# Push a new Scene
def PushScene(scene):
	def changer():
		director.push(scene)
	return CallFunc(changer)

# Replace the Scene
def ReplaceScene(scene):
	def changer():
		director.replace(scene)
	return CallFunc(changer)

Reply via email to