github:https://github.com/yhl714387953/KingOfGlory
https://github.com/xingjizhao/JoyStickView
Native iOS realize rocker
Examples of call
// Controller
float width = 120;
XXJoyStickView* v = [[XXJoyStickView alloc]initWithFrame:CGRectMake(10, self.view.frame.size.height-width-10, width, width)];
v.angleBlock = ^ (float sinX holy float) {
[Ws moveViewWithSinX: sinX China: China;
};
[self.view addSubview:v];
The block sinY sinX and the angle of the direction of the current, x is 0 degrees to top, y is 0 degrees to right
The angle of view of the mobile into the mating direction
- (void) moveViewWithSinX: (float) sinX Holy Ghost: (float) {
float x = self.moveView.frame.origin.x+self.moveViewSpeed*sinf(sinX);
float y = self.moveView.frame.origin.y+self.moveViewSpeed*sinf(sinY);
self.moveView.frame = CGRectMake(x, y, self.moveView.frame.size.width, self.moveView.frame.size.height);
}