skippy_winks
skippy_winks

Reputation: 778

What is the best way to code a D-Pad in Cocos2d?

I have looked all over the internet for this. I was wondering what would be the best way to code a D-Pad that moves a character around the screen? This would be extremely helpful if someone answered. Thanks!

Upvotes: 2

Views: 952

Answers (2)

tallen11
tallen11

Reputation: 1377

I personally like this better.

Cocos2D UI

Upvotes: 0

MCannon
MCannon

Reputation: 4041

to get the joystick, google SneakyInput. its then a case of responding to the direction changes, and either moving the camera, or the character.

CGPoint scaledVelocity= ccpMult(sneakyInputJoystick.velocity, 480.0f);
CGPoint newPosition = ccp(aNode.position.x + scaledVelocity.x * deltaTime, tempNode.position.y + scaledVelocity.y * deltaTime);
[aNode setPosition:newPosition];

Upvotes: 1

Related Questions