Graphics

 View Only
  • 1.  AnimController and waitfor...

    Posted 01-21-2012 15:40
    In a scene simple scene, I have a quad and a text object...

    I only want the quad to move accross my scene, and at the end of the animation (and only at this moment), to write YES in text object...

    So I write the code below, but YES is written at the beginning...

    Dim Quad as xpBaseObject

    Self.GetObjectByName("Quad1", Quad)

    Dim TheText as xpTextObject

    Self.GetObjectByName("Text1", TheText)

    Dim AnimCtl as new xpAnimController

    Self.GetAnimControllerByName("AnimController1", AnimCtl)

    AnimCtl.stop()

    AnimCtl.ClearKeyframes()

    AnimCtl.Position = 0

    AnimCtl.setKeyFramePosition(Quad, 0, 0, 0, 0)

    AnimCtl.setKeyFramePosition(Quad, 200, 1920, 1080, 0)

    AnimCtl.RangeEnd = 200

    AnimCtl.PlayRange(0, 200, True) 'wait for is true but no effect

    TheText.Text = "YES"


    Thank you !


  • 2.  RE: AnimController and waitfor...

    Posted 01-22-2012 12:54
    Hi Vincent, in you original scene, do you by any chance have the text "YES" already in your textobject (for design purposes). If so, then obviously that will be displayed when you put your scene online. So clear the textobject first in your code (i.e. TheText.Text = "" before you put the scene online.

    I haven't tried it myself, but this might solve your problem, since the code looks fine at first glance.

    #XPression


  • 3.  RE: AnimController and waitfor...

    Posted 01-22-2012 15:36
    Hi Gerard,

    My Textbox.text is set to "NO"... Well try ;)

    #XPression


  • 4.  RE: AnimController and waitfor...

    Posted 01-22-2012 16:48
    Hi Vincent,

    I just used your code, be it somewhat changed since I use Delphi instead of VB, and the code runs fine, including the 'wait'.

    #XPression


  • 5.  RE: AnimController and waitfor...

    Posted 01-23-2012 02:38
    Vincent,

    Are you trying to do this through scripting? I don't think you can use WaitFor from a script (only from external API applications).. Maybe you could try something like this instead:

    In OnOnline() use this code:



    Dim Quad as xpBaseObject

    Self.GetObjectByName("Quad1", Quad)

    Dim TheText as xpTextObject

    Self.GetObjectByName("Text1", TheText)

    Dim AnimCtl as xpAnimController

    Self.GetAnimControllerByName("AnimController1", AnimCtl)

    AnimCtl.ClearKeyframes()

    AnimCtl.setKeyFramePosition(Quad, 0, 0, 0, 0)

    AnimCtl.setKeyFramePosition(Quad, 200, 1920, 1080, 0)

    thetext.text = "no"

    self.scenedirector.position=0

    self.scenedirector.play



    And in OnSceneDirectorState() use this:



    Dim TheText as xpTextObject

    Self.GetObjectByName("Text1", TheText)

    if state = 1 then

    TheText.Text = "YES"

    end if



    Also, you don't need the "new" keyword when you declare the xpAnimationController.

    #XPression


  • 6.  RE: AnimController and waitfor...

    Posted 01-24-2012 07:37
    And how to do an animation, update this textbox, do another animation and update same textbox ?

    By the same way ?

    And yes, i'm using this in a script (not api)... Why waitfor is not implemented ? Asynchrone pb ? Debugger says "not in this context" :( It's really practical !

    #XPression


  • 7.  RE: AnimController and waitfor...

    Posted 01-24-2012 08:50
    One thing I can think of, which might not be the best solution but than again: I'm not that familliar with using scripting since I use the API, is to have 3 textboxes and set keyframes for them as well.

    Fill Text1 with the text at the start of the animation, fill Text2 with the text that should be visible after the first animation end fill Text3 with the text that should be visible at the end.

    Text1, with the initial text, would be visible (i.e. alpha = 100) at the start of the animation. At the end of the first part of the animation you keyframe the alpha of Text1 from 100 to 0 and the alpha of Text2 from 0 to 100, and at the end of the second animation you keyframe the alpha of Text2 from 100 to 0 and the alpha of Text3 from 0 to 100.

    This way you also don't need the "waitfor".

    Like I said: it might not be the best solution, but it should work.

    #XPression