|
Click here to download the sample file.
Import an Image from Photoshop
The image will look best if you include an alpha channel.
Choose File-Import... Select your file, Click Import.
Drag and drop the image from the Cast Window on to the Stage Window.
Edit the Score Script with Lingo
Double click the first box in the score script. See the diagram below.
A script window will appear. Type the following behavior in the score script.
on exitFrame go to the frame end
Add a move behavior to the image on the stage.
Select the image on the stage.
Bring up the Window->Inspectors->Property Inspector. Go to the second tab
Hold down the +, select New Behavior Name it moveit Click the script button in the Property Inspector Type the following script:
on exitframe a = the currentSpriteNum sprite(a).locH = sprite(a).locH + 2 end
Hit the play arrow and run this, your image should be moving across the screen to the right.
Use Conditional Statements to change the location of the sprite.
on exitframe a = the currentSpriteNum sprite(a).locH = sprite(a).locH + 2 --move the image to the right continuously.
if sprite(a).locH >= 88 then --if the image has moved past 88 put it to 0. sprite(a).locH = 0 end if
Use a Property and Conditional Statements to change the direction.
property direction -- I made this up, it is not a lingo term.
on beginsprite -- This operator runs once to establish things. a = the currentSpriteNum sprite(a).direction = true end
on exitframe -- This operator runs continuously. a = the currentSpriteNum if sprite(a).direction = true then sprite(a).locH = sprite(a).locH + 2 else sprite(a).locH = sprite(a).locH - 2 end if
if sprite(a).locH >= 88 then sprite(a).direction = false end if
if sprite(a).locH < 9 then sprite(a).direction = true end if
|