Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with rotation! 1

Status
Not open for further replies.

staffni

IS-IT--Management
Mar 10, 2006
2
GB
Hi, I am creating a basic 2d shoot 'em up in director. I want to have the gun rotate (in order to follow the crosshair). Can anyone help me? To give you a better idea heres a screen shot!
Thanks,
Staff, Northern Ireland

 
hey kenneth!.. thanks so much for your reply, that is exactly what i want to do.. i know this is so basic but i can work out the lingo despite your informative post. I assume it should be a behavior script applied to the "gun"..
err...
on beginsprite me
set angle = atan of (y position / x position)
end
??? if you could help me correct this it would be much appreciated!!..
Regards,
STAFF
 
angle = atan of (y position / x position)

This was a concept, not a Lingo script.

The real script will be little bit more complex:

[tt]-- Frame script (Director 10)
on exitFrame me
movieW = the stageRight - the stageLeft
movieH = the stageBottom - the stageTop
h = _mouse.mouseH - movieW/2
v = movieH - _mouse.mouseV
if h <> 0 then
sprite(1).rotation = -atan(v/h)*180/pi
end if
_movie.go(_movie.frame)
end
--[/tt]

Sprite(1) is the object to rotate i.e. "gun".

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top