Como puedo adaptar este código de menu

Amigos de todo expertos tengo este código para realizar un menu tipo orbitante, mi deseo es el siguiente: quiero adaptar este código para que pueda usarlo en la creación de un menu como el de la enciclopedia encarta pero el los sprites persiguen al mouse, habrá posibilidad de una ayuda, les copio el código.

----------------------------------------------------------------------

-- KyRServices copyright 2005 - 2015. --

-- Escrito por TSU Angmerc Carrasquel. --

----------------------------------------------------------------------

-- By reducing either the x or the y in the 'wierd maths stuff' bit below,

-- You get an oval instead of a circle. This makes it 'look' a little 3D.

-- In this example, i have fixed the radius, which makes it a little easier to control.

Property spritenum -- the sprite channel number

Property angle -- this is the sprite's position around the circle in degrees, 0 - 360.

property centerX, centerY   -- The centres of the circle, centerX = Horizontal, centerY = Vertical Centre.

Property stageW -- The Stage width

Property stageH -- The Stage height

-- These are not really neccesary here, but it is handy if the stage may be changing size later,

-- So that you don't have to adjust your code.

-- Hold on tight, we're going in...

On BeginSprite me

-- Declare locals

-- Local variable containing the maximum number of objects in the spin

maxObject = 7

-- declare Properties

stageW = the stageright - the stageleft

stageH = the stageBottom - the stageTop

-- set the centre of the circle in the centre of the stage.

centerX = stageW * 0.5

centerY = stageH * 0.5

-- set the starting angle of the sprite.

angle = (360.0 / maxObject) * spritenum

-- so this will place the sprites around the circle evenly.

end

on exitFrame me

move me

end

on move me

-- some more locals,

-- dir = direction of the spin

if the mouseH > centerX then dir = 1

else dir = -1

-- fixed the radius, to make control of the rotation a little easier with the mouse.

radius = 200

-- the speed that the sprite should spin around the circle.

speed = abs(the mouseH - centerX) * 0.02

--______________________________________________________--

-- wierd maths stuff...

-- If we reduce either of x or y, then we will get an oval instead of a circle...

-- (Try it out on 'Simple Circle' behaviour to see it in its simplest form)

-- Lets set it to 1% of the distance between the mouseV and the vertical centre.

axis = (the mouseV - centerY) * 0.01

x = centerX + cos(angle * pi() /180) * radius

y = centerY + sin(angle * pi() /180) * radius * axis

-- oooh..... A 'z'!

z = sin(angle * pi() /180)

-- This simplest form of sin, (which i still don't understand), returns a number between 1.0 and -1.0

-- We can use this then, to simulate a depth...

-- There are numerous ways, for example changing the blend of a graphic, or the size, etc etc...

--(This is how i did my cube and sphere type things on my website. I will leave that for you to work out....)

-- First turn z into a number between 0 and 2 instead of -1 and 1

z = z + 1

-- smallest is the smallest size we want our sprite to be

smallest = 40

sprite(spritenum).width = smallest + (z * 50)

sprite(spritenum).height = smallest + (z * 50)

--______________________________________________________--

sprite(spritenum).loc = point(x,y)

-- next increase the angle for the next time around - according to our direction and speed locals.

angle = angle + (dir * speed)

end

Añade tu respuesta

Haz clic para o