I am making another game again… But I’ve run into a problem I cannot seem to solve. I need to display text around a perfect circle. How do I curve text? Because I also want to rotate it so it has to be perfectly round. Thanks!
Supereasy.
Create a for loop that creates each letter as a sprite. Your for loop should be something like this:
for i = 1, 20 do local angleDegrees = i\*10 local angleRadians = math.rad(angleDegrees) local circleSize = 100 local sprite = create your image here sprite.x = math.cos(angleRadians)\*circleSize sprite.y = math.sin(angleRadians)\*circleSize sprite.rotation = angleDegrees -- or maybe minus this or plus 90... end
And if you want to spin them, use something like this:
local t = 1 local r = 80 local numPoints = 5 local xCenter = 200 local yCenter = 200 local radius = 80 local rG = 1 -- starting amount of rotation local rotG = 5.5 -- rate at which objects will rotate local angleStep = 2 \* math.pi / numPoints local group = display.newGroup() local group1 = display.newGroup() local t = {} local circle = {} for i = 1, numPoints do circle[i] = display.newRect(0, 0, 10,10) circle[i].x = xCenter + radius\*math.cos(i\*angleStep) circle[i].y = yCenter + radius\*math.sin(i\*angleStep) group1:insert( circle[i] ) end circle[2]:setFillColor(1,0,0) circle[2].width = 40 circle[2].height = 40 group:insert( group1 ) group1.x = display.contentCenterX group1.y = display.contentCenterY local function onSpin( ) rG = rG+rotG for i = 1, numPoints do t[i] = ((rG) \* .014)+ (i\*angleStep) circle[i].x = (r \* math.cos(t[i]))+50 circle[i].y = (r \* math.sin(t[i]))+200 print("circle["..i.."].x = "..circle[i].x) print("circle["..i.."].y = "..circle[i].y) end if rG \>= 450 then rG = 1 end end Runtime:addEventListener( "enterFrame", onSpin )
Supereasy.
Create a for loop that creates each letter as a sprite. Your for loop should be something like this:
for i = 1, 20 do local angleDegrees = i\*10 local angleRadians = math.rad(angleDegrees) local circleSize = 100 local sprite = create your image here sprite.x = math.cos(angleRadians)\*circleSize sprite.y = math.sin(angleRadians)\*circleSize sprite.rotation = angleDegrees -- or maybe minus this or plus 90... end
And if you want to spin them, use something like this:
local t = 1 local r = 80 local numPoints = 5 local xCenter = 200 local yCenter = 200 local radius = 80 local rG = 1 -- starting amount of rotation local rotG = 5.5 -- rate at which objects will rotate local angleStep = 2 \* math.pi / numPoints local group = display.newGroup() local group1 = display.newGroup() local t = {} local circle = {} for i = 1, numPoints do circle[i] = display.newRect(0, 0, 10,10) circle[i].x = xCenter + radius\*math.cos(i\*angleStep) circle[i].y = yCenter + radius\*math.sin(i\*angleStep) group1:insert( circle[i] ) end circle[2]:setFillColor(1,0,0) circle[2].width = 40 circle[2].height = 40 group:insert( group1 ) group1.x = display.contentCenterX group1.y = display.contentCenterY local function onSpin( ) rG = rG+rotG for i = 1, numPoints do t[i] = ((rG) \* .014)+ (i\*angleStep) circle[i].x = (r \* math.cos(t[i]))+50 circle[i].y = (r \* math.sin(t[i]))+200 print("circle["..i.."].x = "..circle[i].x) print("circle["..i.."].y = "..circle[i].y) end if rG \>= 450 then rG = 1 end end Runtime:addEventListener( "enterFrame", onSpin )