Author Topic: move an image  (Read 2806 times)

yomismogarcia

  • Newbie
  • *
  • Posts: 5
    • View Profile
move an image
« on: October 19, 2016, 01:20:05 AM »
Hi all.
I need to make a larger screen image that could move with the help of the cursor. Can somebody help me?
Thank you

yomismogarcia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: move an image
« Reply #1 on: October 21, 2016, 05:57:11 AM »
the answer   ;D ;D ;D ;D :


local slot_a = fe.add_artwork( "image.png", 0, 0);

fe.add_signal_handler( "on_signal" );
       
function on_signal( signal )
{
       local tope = ( fe.layout.height - slot_a.texture_height );
       if ( signal == "down" )
       {
      if ( slot_a.y > tope )
      {
         slot_a.y = ( slot_a.y - 50 );
      }
      else
      {
         slot_a.y = slot_a.y;
      }
       }
       if ( signal == "up" )
       {
             if ( slot_a.y == 0 )
      {
         slot_a.y = slot_a.y;
      }
      else
      {
         slot_a.y = ( slot_a.y + 50 );
      }
       }
       return false;
};
« Last Edit: October 21, 2016, 06:00:53 AM by yomismogarcia »

yomismogarcia

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: move an image
« Reply #2 on: October 25, 2016, 05:03:56 AM »
v2.0  ;D ;D :


local info_a = fe.add_artwork( "image", 24, 24);
info_a.y = 24;

fe.add_signal_handler( "on_signal" );
       

function on_signal( signal )
   {
      local tope = ( fe.layout.height - info_a.texture_height );
      switch ( signal )
      {
      case "up":
         if ( info_a.y == 24 )
         {
            info_a.y = info_a.y;
         }
         else
         {
            info_a.y = ( info_a.y + 50 );
         }
         return true;

      case "down":
         if ( info_a.y > tope )
         {
            info_a.y = ( info_a.y - 50 );
         }
         else
         {
            info_a.y = info_a.y;
         }
         return true;
      }

      return false;
   }