user12925621
user12925621

Reputation:

How do I set up a id for animations?

I am trying to set a id to the animation.

Code:

    def on_anim1_start(self, *args):
        self.x = 0
        sound1 = SoundLoader.load("C:\\Users\\kanna\\Music\\OpenCity1.mp3")
        sound1.play()

    def on_enter(self):
        self.label1.opacity = 0
        animation = Animation(d=3) + Animation(d=4, opacity=1) + Animation(d=5) + Animation(d=4, opacity=0)
        animation.bind(on_start=self.on_anim1_start)
        animation.start(self.label1)

Upvotes: 0

Views: 90

Answers (2)

Sairam Mangeshkar
Sairam Mangeshkar

Reputation: 371

You can use the Inclement's answer with the below answer. So I can ensure you that it works.

def on_anim1_start(self, *args):
    self.x = 0
    sound1 = SoundLoader.load("C:\\Users\\kanna\\Music\\OpenCity1.mp3")
    sound1.play()
def on_enter(self):
    self.label1.opacity = 0
    animation = Animation(d=3) + Animation(d=4, opacity=1) + Animation(d=5) + Animation(d=4, opacity=0)
    animation.bind(on_start=self.on_anim1_start)
    animation.start(self.label1)

Changing the code slightly works for me:

def on_anim1_start(self, *args):
    self.x = 0
    sound1 = SoundLoader.load("C:\\Users\\kanna\\Music\\OpenCity1.mp3")
    sound1.play()
def on_enter(self):
    self.label1.opacity = 0
    @@your_anim = Animation(d=4, opacity=1)
    your_anim.bind(on_start=self.on_anim1_start)@@
    animation = Animation(d=3) + **your_anim** + Animation(d=5) + Animation(d=4, opacity=0)
    animation.start(self.img2)

Note: Remove the asterisk(*) and at(@) before running.

[@@] means added code.  
[**] means edited code.

Upvotes: 0

inclement
inclement

Reputation: 29488

You don't, the Animation doesn't have an id property or accept an id argument. Why do you want to?

Upvotes: 1

Related Questions