- Adjust stick style.

- Add + button for iphone
This commit is contained in:
True Zhuanjia
2024-08-23 21:41:29 +08:00
parent 805cf517bb
commit 747997f46c
2 changed files with 52 additions and 20 deletions
+41 -17
View File
@@ -702,25 +702,27 @@ ICAgICAgICAgICAgIA
</button>
<stackView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RDI-on-aPY">
<rect key="frame" x="240" y="0.0" width="50" height="50"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPA-ea-YHC" userLabel="Save">
<rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="Lot-pn-o60"/>
<constraint firstAttribute="height" constant="50" id="uWO-So-qxr"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" configurationType="pointSize" pointSize="64"/>
</state>
<connections>
<action selector="saveTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="cSe-fN-UWC"/>
</connections>
</button>
</subviews>
</stackView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPA-ea-YHC" userLabel="Save">
<rect key="frame" x="360" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="Lot-pn-o60"/>
<constraint firstAttribute="height" constant="50" id="uWO-So-qxr"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" image="SquareAndArrowDown">
<preferredSymbolConfiguration key="preferredSymbolConfiguration" configurationType="pointSize" pointSize="64"/>
</state>
<connections>
<action selector="saveTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="cSe-fN-UWC"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="rXW-Ms-2cJ" userLabel="Load">
<rect key="frame" x="480" y="0.0" width="50" height="50"/>
<rect key="frame" x="360" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="width" constant="50" id="91g-27-mVH"/>
<constraint firstAttribute="height" constant="50" id="kRj-b6-Bx1"/>
@@ -734,6 +736,28 @@ ICAgICAgICAgICAgIA
<action selector="loadTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="DVp-Xi-K27"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Up4-28-sgF" userLabel="Add">
<rect key="frame" x="480" y="0.0" width="50" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="rWU-US-9dl"/>
<constraint firstAttribute="width" constant="50" id="wWj-wB-MRd"/>
</constraints>
<color key="tintColor" red="0.6705882353" green="0.61568627450000002" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal">
<attributedString key="attributedTitle">
<fragment content="+">
<attributes>
<font key="NSFont" size="50" name="Arial-BoldMT"/>
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural" tighteningFactorForTruncation="0.0"/>
</attributes>
</fragment>
</attributedString>
</state>
<connections>
<action selector="addTapped:" destination="ZYS-Zm-PJs" eventType="touchUpInside" id="idY-3m-m01"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstAttribute="width" constant="530" id="6BK-sG-WTH"/>
+11 -3
View File
@@ -105,6 +105,7 @@ static float LS_CENTER_X;
static float LS_CENTER_Y;
static float RS_CENTER_X;
static float RS_CENTER_Y;
static const float STICK_OPACITY = 0.63;
static float START_X;
static float START_Y;
@@ -697,6 +698,7 @@ static float L3_Y;
UIImage* leftStickImage = [UIImage imageNamed:@"StickInner"];
_leftStick.frame = CGRectMake(LS_CENTER_X - leftStickImage.size.width / 2, LS_CENTER_Y - leftStickImage.size.height / 2, leftStickImage.size.width, leftStickImage.size.height);
_leftStick.contents = (id) leftStickImage.CGImage;
_leftStick.opacity = STICK_OPACITY; // make stick half transparent when it's idle
[_view.layer addSublayer:_leftStick];
// create right analog stick
@@ -711,12 +713,13 @@ static float L3_Y;
_rightStick.frame = CGRectMake(RS_CENTER_X - rightStickImage.size.width / 2, RS_CENTER_Y - rightStickImage.size.height / 2, rightStickImage.size.width, rightStickImage.size.height);
_rightStick.contents = (id) rightStickImage.CGImage;
_rightStick.opacity = STICK_OPACITY; // make stick half transparent when it's idle
[_view.layer addSublayer:_rightStick];
// make stick larger
if(_largerStickLR1){
STICK_INNER_SIZE = rightStickImage.size.width *1.37;
STICK_OUTER_SIZE = rightStickBgImage.size.width *1.17;
STICK_INNER_SIZE = rightStickImage.size.width *1.33;
STICK_OUTER_SIZE = rightStickBgImage.size.width *1.10;
_rightStick.bounds = _leftStick.bounds = CGRectMake(0, 0, STICK_INNER_SIZE, STICK_INNER_SIZE);
_rightStickBackground.bounds = _leftStickBackground.bounds = CGRectMake(0, 0, STICK_OUTER_SIZE, STICK_OUTER_SIZE);
}
@@ -907,7 +910,8 @@ static float L3_Y;
button.cornerRadius = 45;
// 使用 shadowPath 定义阴影形状和扩展范围
CGFloat spread = 15; // 扩散的大小
CGFloat spread = 15; // 扩散的大小gggkkkoooovv
if([button.name isEqualToString:@"leftStick"] || [button.name isEqualToString:@"rightStick"]) spread = 12;
CGRect largerRect = CGRectInset(button.bounds, -spread, -spread);
UIBezierPath *shadowPath = [UIBezierPath bezierPathWithRoundedRect:largerRect cornerRadius:button.cornerRadius];
button.shadowPath = shadowPath.CGPath;
@@ -1044,6 +1048,7 @@ static float L3_Y;
_r3Touch = touch;
updated = true;
} else if ([_leftStick.presentationLayer hitTest:touchLocation]) {
_leftStick.opacity = 1.0; // make stick opaque while being moved
if (l3TouchStart != nil) {
// Find elapsed time and convert to milliseconds
// Use (-) modifier to conversion since receiver is earlier than now
@@ -1059,6 +1064,7 @@ static float L3_Y;
_lsTouch = touch;
stickTouch = true;
} else if ([_rightStick.presentationLayer hitTest:touchLocation]) {
_rightStick.opacity = 1.0; // make stick opaque while being moved
if (r3TouchStart != nil) {
// Find elapsed time and convert to milliseconds
// Use (-) modifier to conversion since receiver is earlier than now
@@ -1173,6 +1179,7 @@ static float L3_Y;
} else if (touch == _lsTouch) {
_leftStick.frame = CGRectMake(LS_CENTER_X - STICK_INNER_SIZE / 2, LS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
_leftStick.shadowOpacity = 0.0;
_leftStick.opacity = STICK_OPACITY; // reset stick to half transparent
[_controllerSupport updateLeftStick:_controller x:0 y:0];
[_controllerSupport clearButtonFlag:_controller flags:LS_CLK_FLAG];
l3TouchStart = [NSDate date];
@@ -1181,6 +1188,7 @@ static float L3_Y;
} else if (touch == _rsTouch) {
_rightStick.frame = CGRectMake(RS_CENTER_X - STICK_INNER_SIZE / 2, RS_CENTER_Y - STICK_INNER_SIZE / 2, STICK_INNER_SIZE, STICK_INNER_SIZE);
_rightStick.shadowOpacity = 0.0;
_rightStick.opacity = STICK_OPACITY;
[_controllerSupport updateRightStick:_controller x:0 y:0];
[_controllerSupport clearButtonFlag:_controller flags:RS_CLK_FLAG];
r3TouchStart = [NSDate date];