HD dPad buttons

This commit is contained in:
TrueZhuangjia committed 2024-10-13 22:00:49 +08:00
1 parent 3bec2d6e65
commit 962d19f3cb
9 files changed
+99 -12

No files matched your search

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "DownButtonHD.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "LeftButtonHD.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "RightButtonHD.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "UpButtonHD.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

+15 -12
View File
@@ -582,23 +582,25 @@ static float L3_Y;
[_view.layer addSublayer:_yButton]; [_view.layer addSublayer:_yButton];
// Calculate the distances of each button from the shared center based on their transformed positions // Calculate the distances of each button from the shared center based on their transformed positions
CGFloat newDPadDistFactor = 0.1/_dPadSizeFactor; CGFloat newDPadDistFactor = 0.2/_dPadSizeFactor;
CGFloat newLongSideLength = standardLeftRightButtonBounds.size.width * _dPadSizeFactor; CGFloat newLongSideLength = standardLeftRightButtonBounds.size.width * _dPadSizeFactor;
CGFloat newShortSideLength = standardLeftRightButtonBounds.size.height * _dPadSizeFactor; CGFloat newShortSideLength = standardLeftRightButtonBounds.size.height * _dPadSizeFactor;
CGPoint sharedCenter = CGPointMake(D_PAD_CENTER_X, D_PAD_CENTER_Y); // this will anchor the center point of the dPad CGPoint sharedCenter = CGPointMake(D_PAD_CENTER_X, D_PAD_CENTER_Y); // this will anchor the center point of the dPad
// dPad buttons are resized HERE // dPad buttons are resized HERE
// up button // up button
UIImage* upButtonImage = [UIImage imageNamed:@"UpButton"]; // UIImage* upButtonImage = [UIImage imageNamed:@"UpButton"];
_upButton.contents = (id) upButtonImage.CGImage; UIImage* upButtonHdImage = [UIImage imageNamed:@"UpButtonHD"];
_upButton.contents = (id) upButtonHdImage.CGImage;
[_view.layer addSublayer:_upButton]; [_view.layer addSublayer:_upButton];
_upButton.anchorPoint = CGPointMake(0.5, 1 + newDPadDistFactor); _upButton.anchorPoint = CGPointMake(0.5, 1 + newDPadDistFactor);
_upButton.bounds = CGRectMake(0, 0, newShortSideLength, newLongSideLength); _upButton.bounds = CGRectMake(0, 0, newShortSideLength, newLongSideLength);
_upButton.position = CGPointMake(sharedCenter.x, sharedCenter.y); _upButton.position = CGPointMake(sharedCenter.x, sharedCenter.y);
// down button // down button
UIImage* downButtonImage = [UIImage imageNamed:@"DownButton"]; // UIImage* downButtonImage = [UIImage imageNamed:@"DownButton"];
_downButton.contents = (id) downButtonImage.CGImage; UIImage* downButtonHdImage = [UIImage imageNamed:@"DownButtonHD"];
_downButton.contents = (id) downButtonHdImage.CGImage;
[_view.layer addSublayer:_downButton]; [_view.layer addSublayer:_downButton];
// Resize and reposition the button // Resize and reposition the button
_downButton.anchorPoint = CGPointMake(0.5, 0 - newDPadDistFactor); _downButton.anchorPoint = CGPointMake(0.5, 0 - newDPadDistFactor);
@@ -606,16 +608,18 @@ static float L3_Y;
_downButton.position = CGPointMake(sharedCenter.x, sharedCenter.y); _downButton.position = CGPointMake(sharedCenter.x, sharedCenter.y);
// left button // left button
UIImage* leftButtonImage = [UIImage imageNamed:@"LeftButton"]; // UIImage* leftButtonImage = [UIImage imageNamed:@"LeftButton"];
_leftButton.contents = (id) leftButtonImage.CGImage; UIImage* leftButtonHdImage = [UIImage imageNamed:@"LeftButtonHD"];
_leftButton.contents = (id) leftButtonHdImage.CGImage;
[_view.layer addSublayer:_leftButton]; [_view.layer addSublayer:_leftButton];
_leftButton.anchorPoint = CGPointMake(1 + newDPadDistFactor, 0.5); _leftButton.anchorPoint = CGPointMake(1 + newDPadDistFactor, 0.5);
_leftButton.bounds = CGRectMake(0, 0, newLongSideLength, newShortSideLength); _leftButton.bounds = CGRectMake(0, 0, newLongSideLength, newShortSideLength);
_leftButton.position = CGPointMake(sharedCenter.x, sharedCenter.y); _leftButton.position = CGPointMake(sharedCenter.x, sharedCenter.y);
// right button // right button
UIImage* rightButtonImage = [UIImage imageNamed:@"RightButton"]; // UIImage* rightButtonImage = [UIImage imageNamed:@"RightButton"];
_rightButton.contents = (id) rightButtonImage.CGImage; UIImage* rightButtonHdImage = [UIImage imageNamed:@"RightButtonHD"];
_rightButton.contents = (id) rightButtonHdImage.CGImage;
[_view.layer addSublayer:_rightButton]; [_view.layer addSublayer:_rightButton];
_rightButton.anchorPoint = CGPointMake(0 - newDPadDistFactor, 0.5); _rightButton.anchorPoint = CGPointMake(0 - newDPadDistFactor, 0.5);
_rightButton.bounds = CGRectMake(0, 0, newLongSideLength, newShortSideLength); _rightButton.bounds = CGRectMake(0, 0, newLongSideLength, newShortSideLength);
@@ -1636,7 +1640,7 @@ static float L3_Y;
if (layer == self._dPadBackground){ if (layer == self._dPadBackground){
// Calculate the distances of each button from the shared center based on their transformed positions // Calculate the distances of each button from the shared center based on their transformed positions
CGFloat newDPadDistFactor = 0.1/sizeFactor; CGFloat newDPadDistFactor = 0.2/sizeFactor;
// 1. Resize and reposition the Down button // 1. Resize and reposition the Down button
@@ -1646,8 +1650,7 @@ static float L3_Y;
// this will anchor the center point of the dPad // this will anchor the center point of the dPad
// must * _dPadSizeFactor (the current size factor retrieved from selected osc profile) // must * _dPadSizeFactor (the current size factor retrieved from selected osc profile)
CGPoint sharedCenter = CGPointMake(standardLeftRightButtonBounds.size.width * _dPadSizeFactor, standardLeftRightButtonBounds.size.width * _dPadSizeFactor); CGPoint sharedCenter = CGPointMake(standardLeftRightButtonBounds.size.width * _dPadSizeFactor + 10, standardLeftRightButtonBounds.size.width * _dPadSizeFactor + 10); //this will anchor the center point of the dPad
//CGPoint sharedCenter = CGPointMake(0, 0); // this will anchor the center point of the dPad
// Resize and reposition the Up button // Resize and reposition the Up button
_upButton.anchorPoint = CGPointMake(0.5, 1 + newDPadDistFactor); _upButton.anchorPoint = CGPointMake(0.5, 1 + newDPadDistFactor);