question abt rotating a characters arm

Hi guys,

I have a situation I have a character on the middle of the screen… when the screen is touched I want the users hand to rotate in the direction of the touch location…

To achieve this I have two separate images

  1. character body only - no arms
  2. characters arms only

then i worked out the angle between the characters body and the touch location, then used the rotation property on the characters arms… it works… but it just doesn’t look the best…

how would you go about trying to achieve this? is there a better way?
any suggestions would be appreciated

Thanks

[import]uid: 67619 topic_id: 23710 reply_id: 323710[/import]

Please don’t make dupe threads.

Re the arm, how does it not look the best? Would making it transition rather than instantly move perhaps help? [import]uid: 52491 topic_id: 23710 reply_id: 95375[/import]

sorry peach… was not sure where to place it… my bad…

in terms of the arm… it just looks dis-jointed… is this the way everyone does it?

I added a head to the character as well… so the head moves… so it looks like the character is looking at where the touch happened… because of the rotation angle… it looks like the head has been decapitated :stuck_out_tongue: maybe i need to adjust the x and y off set depending on the angle? [import]uid: 67619 topic_id: 23710 reply_id: 95378[/import]

HAHAHAHA! I laughed out loud at “it looks like the head has been decapitated” ^-^;

Yeah, I’d consider working some kind of offset in there, you don’t want to scare anyone :wink:

How are you setting the reference point? Keep in mind that can have an impact of course.

Peach :slight_smile: [import]uid: 52491 topic_id: 23710 reply_id: 95398[/import]

Peach…

Yeah tried the offsets… also tried with the leftcenterRef and the centerref…

is there any other ways to do this? or you recommend this way?

Thanks

[import]uid: 67619 topic_id: 23710 reply_id: 95401[/import]

Maybe it’s a matter of how the graphics look together; needing a shoulder or the like.

Run this and see what you think;

[lua]local body = display.newRect( 140, 100, 40, 100 )
local shoulder = display.newCircle( 160, 150, 10 )
shoulder:setFillColor(100, 0, 0)
local arm = display.newRect( 160, 140, 60, 20 )
arm:setFillColor(100, 0, 0)
arm:setReferencePoint(display.CenterLeftReferencePoint)

local function spinArm()
arm.rotation = arm.rotation + 1
end
Runtime:addEventListener(“enterFrame”, spinArm)[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 23710 reply_id: 95632[/import]