Skip to content

Commit

Permalink
Adjust mobile joystick
Browse files Browse the repository at this point in the history
  • Loading branch information
m110 committed Nov 3, 2024
1 parent 2e197b2 commit bccbc35
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 5 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,16 @@ Enemies are spawned once the top camera boundary reaches their position.
A group spawn spawns all connected enemies at once.

All objects despawn once they go out of screen.

### Mobile Development Notes

1. `task mobile` to create the `Airplanes.xcframework`.
2. Open the Xcode project and deploy.
3. If the app takes long to launch, <kbd>Cmd</kbd> + <kbd>Shift</kbd> + <kbd>,</kbd> and disable the "Debug executable" option.

#### Creating a new mobile project

1. Create a new Xcode project (Game, SpriteKit).
2. Add the `Airplanes.xcframework` to the project as a framework.
3. Add the `GameController.framework` to the project as a framework.
4. Update `GameViewController` to use `MobileEbitenViewController`.
2 changes: 1 addition & 1 deletion archetype/joystick.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewJoystick(w donburi.World, pos math.Vec2) *donburi.Entry {
})
t := transform.Transform.Get(joystick)
t.LocalPosition = pos
t.LocalScale = math.Vec2{X: 0.5, Y: 0.5}
t.LocalScale = math.Vec2{X: 0.2, Y: 0.2}

knob := w.Entry(w.Create(
transform.Transform,
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1610"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35C1A9B32CD64A7700B39F17"
BuildableName = "Airplanes.app"
BlueprintName = "Airplanes"
ReferencedContainer = "container:Airplanes.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35C1A9D12CD64A7900B39F17"
BuildableName = "AirplanesTests.xctest"
BlueprintName = "AirplanesTests"
ReferencedContainer = "container:Airplanes.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35C1A9DB2CD64A7900B39F17"
BuildableName = "AirplanesUITests.xctest"
BlueprintName = "AirplanesUITests"
ReferencedContainer = "container:Airplanes.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35C1A9B32CD64A7700B39F17"
BuildableName = "Airplanes.app"
BlueprintName = "Airplanes"
ReferencedContainer = "container:Airplanes.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "35C1A9B32CD64A7700B39F17"
BuildableName = "Airplanes.app"
BlueprintName = "Airplanes"
ReferencedContainer = "container:Airplanes.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,23 @@
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>35C1A9B32CD64A7700B39F17</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>35C1A9D12CD64A7900B39F17</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>35C1A9DB2CD64A7900B39F17</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
5 changes: 1 addition & 4 deletions system/controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (i *Controls) Update(w donburi.World) {
X: float64(touchX) - joystickPos.X,
Y: float64(touchY) - joystickPos.Y,
}
maxRadius := 100.0
maxRadius := 20.0
length := knobMove.Magnitude()

// Get direction vector before clamping (this will be normalized)
Expand All @@ -85,10 +85,7 @@ func (i *Controls) Update(w donburi.World) {
}

movementFactor := stdmath.Min(length/maxRadius, 1.0)
factor := 0.5

// Scale knob visual position
knobMove = knobMove.MulScalar(factor)
knob := hierarchy.MustGetChildren(joystick)[0]
knobTransform := transform.Transform.Get(knob)
knobTransform.LocalPosition = knobMove
Expand Down

0 comments on commit bccbc35

Please sign in to comment.