Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Tweening in movieclips — Gideros Forum

Tweening in movieclips

saeyssaeys Member
edited November 2016 in General questions
This is not a question, merely a note to self (and others) about tweening in movieclips:
function movieClips()
 
  mcA = movieClip.new{
    {1,10, thisSprite}
  }
 
  mcB = movieClip.new{
    {1,10, thatSprite, {tweening properties}}
  }
 
  function levelA()
    control movieClip mcA here
  end
 
  function levelB()
    control movieClip mcB here
  end
 
end
...results in strange and inconsistent tweening of the mcB movieclip, if it's played AFTER mcA, at least in my case.
Putting the movieclips inside the respective controlling functions returns correct tweening. :-)

Comments

  • this should not happen, perhaps the problem is that you write
    movieClip.new()
    instead of
    MovieClip.new()
    ?
    (this should actually throw an error except if you have a movieClip already defined, in which case it could do strange things like the one you explain in your post).

  • Well, sorry, MovieClip.new() it is.

    No errors, just tweens that doesn't behave as defined (as far as I can see some scale tweens that got lost and some tweens that happened at other frames than defined). All movieclips are named differently.

    The tweens were correct if mcB were played first, and also when repeated.
    Not correct if played after mcA, also not correct when mcB is repeated after that.
  • keszeghkeszegh Member
    edited November 2016
    it's still strange if these movieclips use different sprites. if you can share your code maybe the problem will be noticeable.
  • hgy29hgy29 Maintainer
    Yes @saeys, please share a sample code that shows the issue. If it is a gideros bug we'll try to fix it then.
  • Well, you asked for it, here's a excerpt from my n00b code: :-B
    function playnoCard()
    -- Dra --
      function noCard_Dra()
        animEyes_Dra = MovieClip.new{
          {1, 360, glasses },
          -- more movieclip lines here, no tweens
          {351, 360, eyebrowsesUp},
        }
     
        anim_Dra = MovieClip.new{
          {1,  355,  markskugga	},
          {1,  355,  static	},
          {1,  7  ,  TDN	},
          {8,  18 ,  Asmall	},
          -- lipsync lines here, no tweens
          {303, 355, idleSmile	},
        }
     
        guideAnim_Dra = MovieClip.new{
          {17,26,cardP,{x = cf:getX()+59+150, y = cf:getY()-cf:getHeight()/2+58+60, alpha = {0, 0.4, "inOutCubic"}} },
          {27,60,cardP},
          {61,90,cardP,{x={cf:getX()+59+150,(sf:getX()-59 - 100),"inOutCubic"}, y={cf:getY()-cf:getHeight()/2+58 + 60,(sf:getY()+58 + 70),"inOutCubic"}}},
          {91,100,cardP,{scale={1.3,1.0, "inOutCubic"}}},
          {101,340,cardP},
          {341,350,cardP,{alpha = {0.4, 0, "inOutCubic"}}},
          {106,115,cardA,{x = vf:getX()-59-170, y = vf:getY()-vf:getHeight()/2+58+80, alpha = {0, 0.4, "inOutCubic"}} },
          {116,149,cardA	},
          {150,180,cardA,{x={vf:getX()-59-170,(sf:getX()-59+150),"inOutCubic"}, y={vf:getY()-vf:getHeight()/2+58+80,(sf:getY()+58+70),"inOutCubic"}}},
          {181,190,cardA,{scale={1.3,1.0, "inOutCubic"}}},
          {191,340,cardA	},
          {341,350,cardA,{alpha = {0.4, 0, "inOutCubic"}}},
          {250,350,playHit,{x = conf.dx+conf.halfWidth+sf:getWidth()/4+148, y = sf:getY()+sf:getHeight()/10+233, scale = {1,3,"outCubic"}, alpha = {0.8,0,"outCubic"}}},
        }
     
        local noCard_DraEnd = function()
          stopButton:removeEventListener("finger-up", stopNoCard_Dra)
          buttonsGroup:removeChild(stopButton)
          buttonsGroup:addChild(playButton)
          self:addChild(playInvisibleButton)
          self:removeChild(anim_Dra)
          self:removeChild(animEyes_Dra)
          self:removeChild(guideAnim_Dra)
          infoButton:addEventListener("finger-up", addAdultMessage)
          idle()
        end
        local soundfile = string.sub(whatToPlay,5)
        sound = Sound.new("sounds/" .. soundfile .. ".mp3")
        self:addChild(anim_Dra)
        self:addChild(animEyes_Dra)
        self:addChild(guideAnim_Dra)
        cardP:setScale(1.3)
        cardA:setScale(1.3)
        channel:setVolume(volym)
        channel = sound:play()
        channel:setVolume(volym)
        stopButton:addEventListener("finger-up", stopNoCard_Dra)
        anim_Dra:addEventListener(Event.COMPLETE, noCard_DraEnd)
      end
     
      --Hej --
      function noCard_Hej()
        anim_Hej = MovieClip.new{
          {1,33,markskugga	},
          {1,33,static},
          {1,4,idleSmile},
          {5,20,E},
          {21,33,I	},
        }
        animEyes_Hej = MovieClip.new{
          {1,33,glasses 		},
          {1,33, look			},
          {1,10,eyebrowses		},
          {11,33,eyebrowsesUp	},
        }
        local function noCard_HejEnd()
          self:removeChild(anim_Hej)
          self:removeChild(animEyes_Hej)
          buttonsGroup:removeChild(playButtonRunning)
          buttonsGroup:addChild(playButton)
          self:addChild(playInvisibleButton)
          anim_Hej:stop()
          animEyes_Hej:stop()
          infoButton:addEventListener("finger-up", addAdultMessage)
          idle()
        end
        self:addChild(anim_Hej)
        self:addChild(animEyes_Hej)
        sound = Sound.new("sounds/hej.mp3")
        channel:setVolume(volym)
        channel = sound:play()
        channel:setVolume(volym)
        buttonsGroup:removeChild(stopButton)
        buttonsGroup:addChild(playButtonRunning)
        anim_Hej:addEventListener(Event.COMPLETE, noCard_HejEnd)
      end
    end
     
    --below code that control which noCard function (Dra och Hej) is to be played
    This code is the one that is working as expected.
    I can recreate the "problem" by moving line 3 (function playnoCard()) to about line 34 (after the third movieclip guideAnim_Dra), leaving the movieclips outside the function that controls them, then the tweens doesn't behave as expected when played AFTER the last movieclip animEyes_Hej.

    I guess one could try to recreate this with a simplier from-the-scratch example code, but I haven't got the time to do that (yet).

    You may have other comments about my code (optimization etc), but please focus on the problem at hand. B-)
  • Love the Swedish comments and variable names. Go Sweden!

    Likes: saeys

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • i tried to decipher your code but it contains too much noise, i can't find the problem, especially that you shared the working one and not the non-working one, so i even have to change lines in my head. so i gave up after a while.
    at least you could make it work properly, even though you never got the cause of the problem.

    Likes: saeys

    +1 -1 (+1 / -0 )Share on Facebook
  • i tried to decipher your code but it contains too much noise,
    I understand. :-) As said, when I have the time I'll make a clean version of this code in order to recreate the problem from scratch. But as it's working in one way right now it's just not a priority... :-)
Sign In or Register to comment.