开发者

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

开发者 https://www.devze.com 2023-02-17 08:31 出处:网络
I have looked all over the int开发者_运维问答ernet 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 som

I have looked all over the int开发者_运维问答ernet 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!


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];


I personally like this better.

Cocos2D UI

0

精彩评论

暂无评论...
验证码 换一张
取 消