by Vivienne Trulock
If you are doing your own interactive map, you might find that your map is larger than the space you have allocated for it. There are some simple techniques you can use to make the map moveable by the user.
Import the map images to begin this exercise. When importing 'surround.gif', uncheck the 'Trim White Space' checkbox as we need this to cover the rest of our map
Open your movie properties window and set your stage to be 1024*768
Place the map on row 1 of the score in position (274,300) - use X-Y coordinates
Place the surround on the stage in position (514, 384). Set the background colour to be #FF9900 (the colour of the box) and then set the backgroound to be transparent. We now have a window through which we can se the map.
Drag arrows around the window and use the rotate tool in the arrow sprite properties window to make the arrows point outwards from the map indicating the direction the map will move when the arrows are clicked.
Assign the scripts below to the arrows. The scripts first use an 'if' statement to check that the map is within a certain space, so that when the user is clicking the arrow to move it, they never see the map edge.
LocH refers to the horizontal location of the map (the map's position on the X-axis).
LocV refers to the vertical location of the map (the map's position on the Y-axis).
The third line dynamically reassigns the sprite's location value to its own value plus or minus 20 pixels, thus moving it forwards or backwards in the Horizontal or Vertical planes.
Right Arrow
on mousedown me
if sprite(1).locH>180 then
sprite(1).locH=sprite(1).locH-20
end if
end
Down Arrow
on mousedown me
if sprite(1).locV>210 then
sprite(1).locV=sprite(1).locV-20
end if
end
Left Arrow
on mousedown me
if sprite(1).locH<350 then
sprite(1).locH=sprite(1).locH+20
end if
end
Up Arrow
on mousedown me
if sprite(1).locV<300 then
sprite(1).locV=sprite(1).locV+20
end if
end
On the final frame of the movie put a loop script
on exitFrame me
go to the frame
end
See the final movie