7 Replies Latest reply on May 5, 2008 1:03 PM by m_saade

    Help

    m_saade Level 1
      Hello all,

      i am new to this forum as to lingo and director, i need the code for making a picture move randomly within the borders of the stage (500*500) on mouseenter.

      as i want to make a picture bounce on the edges of the stage and i used this code for it :

      On exitframe me
      go the frame
      anim="left"
      If anim="left" then
      Sprite(5) .loch = sprite(5).loch + 5
      If sprite(5).loch >= 459 then
      Anim= "right"
      End if
      else
      sprite(5).loch = sprite(5).loch -5
      If sprite(5).loch <= 50 then
      Anim = "left"
      End if
      End if
      end

      this code it set on the last frame. and its not working, the picture doesnt bounce, instead it keeps moving as in anim="left".
      can some1 help me solving this problem ?

      thank you


        • 1. Help
          Chunick Level 3
          check out some of the amazing work here:
          www.jmckell.com

          that should get you started.
          • 2. Re: Help
            multiduck
            If you look at your code you can see at the third line that you have hard coded which direction the image should move, that's what makes it always go left (anim="left")

            Also move go the frame to the end of exitframe. The rest of the code should preferably be run in enterframe since time consuming code in exitframe can make your program run slower (due to how director calculates frame rate delays)

            Any way, use anim as a global variable and set random initial direction of the variable in either a startMovie script or in the frame script of an earlier frame.

            • 3. Re: Help
              m_saade Level 1
              thx for the remark.. i got it working now.
              but i still need the code for the random thing i mentioned above if someone can help.
              • 4. Re: Help
                multiduck Level 1
                This should work for you if I understood you correctly.
                • 5. Re: Help
                  m_saade Level 1
                  i need the random animation for a new sprite, its not related to the anim="left" ...
                  what i need is the code to make a sprite on mouseenter, disappear and appear in a random place within the 500*500 stage.

                  and josh i check the websites.. they are useful but i need an ebook or a website where i can get lessons and examples in lingo, starting from the basics..
                  for i need help to make a game as a university project, and the codes i learned are very basic.
                  • 6. Help
                    multiduck Level 1
                    Ah, you can still use most of the same code tho.

                    And here is a free ebook about game programming with director http://garyrosenzweig.com/advancedlingoforgames/ it used to be in print so if you like it support the author by buying his other book, details on the linked page.

                    edit: Note this code should work with any size stage and sprite.
                    • 7. Re: Help
                      m_saade Level 1
                      thank u alot for ur help.. i really appreciate it
                      regards