Spinning wheel "CUT THE ROPE"

Good Evening friends,

I am trying to make a "wheel" with the same action of the spinning wheel game CUT THE ROPE. Here is a sample image, you see the idea is when I click and rotate to one side with your finger in circular motion it performs an action when turning to the other side in the same circular motion rudder performs another action.

Can anyone give me an example or idea how to do? I've tried various ways and have not had good results.

Sample Image -> http://imageshack.us/photo/my-images/217/cuttherope.jpg/

thanks

try this

note :- this is not fully optimized or tested code it is just for reference how to achieve that thing (it may have bug(s))

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local physics = require "physics"
physics.start()
--physics.setDrawMode("hybrid")
 
local line1 = display.newRect(100,100,5,100)
 
 
local line2 = display.newRect(100,100,5,100)
line2.rotation = 90
 
local circle = display.newCircle(100,150,15)
physics.addBody(circle,"static")
local lines = {}
 
local isReverse = 1
local function rotate()
if isReverse == 1 then
 
    line1.rotation = line1.rotation + 5
    line2.rotation = line2.rotation + 5
    if #lines == 0 then
       lines[#lines + 1] = display.newRect(0,0,1,3)
        lines[#lines].x = circle.x + circle.width * 0.5
        lines[#lines].y = circle.y
        physics.addBody(lines[#lines],{density = 0.01})
    else
         lines[#lines + 1] = display.newRect(0,0,1,3)
        lines[#lines].x = circle.x + circle.width * 0.5
        lines[#lines].y = lines[#lines - 1].y + lines[#lines - 1].height
        physics.addBody(lines[#lines],{density = 0.01})
    end
    if #lines == 1 then
        myJoint = physics.newJoint( "pivot", lines[#lines], circle, lines[#lines].x,lines[#lines].y )
    else
        myJoint = physics.newJoint( "pivot", lines[#lines], lines[#lines - 1], lines[#lines].x,lines[#lines].y )
    end
    myJoint:setRotationLimits( -45, 45 )
else
    line1.rotation = line1.rotation - 5
    line2.rotation = line2.rotation - 5
    lines[#lines]:removeSelf()
    lines[#lines] = nil
end
end
timer.performWithDelay(70,rotate,0)
 
local function changeDirection()
    isReverse = 1 - isReverse
end
 
local button = display.newText("tap me to change direction",200,0,native.systemFont,36)
button:addEventListener("tap",changeDirection)

Almost my friend,

note that in his example he must click on the "tap me to change direction" "to change the direction of the rudder, but what I need is to change the wheel rotation when I make a circular motion with my finger, you know ? I'll click the wheel and make circular motion to the right and the rope will decrease or I'll click with my finger and make circular motion to the left and the rope will increase, right? the action of the string is ok, just change the only part of how activates it, as described above.

Thanks

@Dhennrich:-

yup i know which type of functionality is in the cut the rope that's wonderful game and as i had said it is just for reference
now you have basic idea try to play with this basic idea and achieve what you want

:)

views:1874 update:2011/9/28 21:38:26
corona forums © 2003-2011