Lingo Tutorial: Widescreen (and mouse coordinates)

READING: Manual pages of the commands described here

File "wideScreen.dir"

Moving the cursor to the left or the right border of the screen will move the background image to reveal its hidden sides. This is very useful when you want to create the feeling of exploring spaces (e.g., looking around a room).

on exitFrame me
    -- Moving the cursor to the left or right side of the screen 
    -- (within 10 pixels from the screen border), reveals parts of the hidden picture
                         
    -- screen size is assumed 320 by 240
    if (_mouse.mouseH < 10 and sprite(1).locH >0) then
       sprite(1).locH = sprite(1).locH - 5
    end if
                         
   if (_mouse.mouseH > 310 and sprite(1).locH < 320) then
      sprite(1).locH = sprite(1).locH + 5
    end if 
 end

Do you like the way the background screen is moving? Notice that there is something unnatural about the movement of Corto Maltese in the background. For example, when the cursor is on the left of the image one might expect to see more of the hidden left side. Instead you see more of the right side. How do you fix it?

(The interaction would be more believable if you had the right cursor indicate the kind of scrolling you are expecting. If you are familiar with cursor changing, add the appropriate cursor to your solution.)

You can control whether you can click and drag a sprite by selecting the movableSprite property. Here is another way in Lingo of picking up and moving an image around without using the 'moveableSprite' property. It can be used in conjunction of other code (like monitoring the degree of movement, etc.)

 -- clicking and dragging the image will allow moving it around.
 on mouseDown me
     global moving
     sprite(1).loc = _mouse.mouseloc
     moving = 1
 end
 on mouseWithin
     global moving
     if moving = 1 then
        sprite(1).loc = _mouse.mouseloc
     end if
 end
 on mouseUp
     global moving
     moving = 0
 end

 

Maintained By: Takis Metaxas
Last Modified: October 22, 2012