Docs
Device and Network
Network
.getNetworkType
Reports current network type and basic connection quality indicators.
Parameters
Field | Type | Description | Required |
success | function | Callback function for successful interface call | No |
fail | function | Callback function for interface call failure | No |
complete | function | Callback function for the end of interface call (executed upon both successful and failed calls) | No |
Response object (success callback)
Field | Type | Description |
networkType | string | Network Type |
signalStrength | Number | Signal strength, unit: dbm |
hasSystemProxy | Boolean | Does the device use a network proxy? |
weakNet | Boolean | Is it in a weak connection environment? |
Example
TTMinis.game.getNetworkType({
success (res) {
const networkType = res.networkType
const weakNet = res.weakNet
}
})Touch
APIs for handling touch input. Each listener callback receives a res object containing touches (all current points), changedTouches (points that triggered the event), and a timeStamp.
- onTouchStart(listener) / offTouchStart(listener): Listen for or remove a listener for the start of a touch event.
- onTouchMove(listener) / offTouchMove(listener): Listen for or remove a listener for movement during a touch event.
- onTouchEnd(listener) / offTouchEnd(listener): Listen for or remove a listener for the end of a touch event.
- onTouchCancel(listener) / offTouchCancel(listener): Listen for or remove a listener for when a touch event is interrupted.
A Touch object (touch array) represents a touch point on a touch device. It typically refers to the action of a finger or stylus on a touchscreen device or touchpad.
- number identifier: The Touch object's unique identifier, a read-only property. This identifier remains unchanged throughout the entire movement of a touch action (referring to a finger's touch) on a plane. It can be used to determine whether the tracked action is the same touch event.
- number screenX: The X coordinate of the touch point relative to the left edge of the screen.
- number screenY: The Y coordinate of the touch point relative to the edge of the screen.
.onTouchStart
Listens for the start of a touch interaction.
Response object
Field | Type | Description |
touches | Array<object> | Touch array. List of all current touchpoints |
changedTouches | Array<object> | Touch array. The list of touchpoints that triggered this event |
timeStamp | number | Timestamp when the event is triggered |
.onTouchMove
Listens for touch movement events.
Response object
Field | Type | Description |
touches | Array<object> | Touch array. List of all current touchpoints |
changedTouches | Array<object> | Touch array. The list of touchpoints that triggered this event |
timeStamp | number | Timestamp when the event is triggered |
.onTouchEnd
Listens for the end of a touch interaction.
Response object
Field | Type | Description |
touches | Array<object> | Touch array. List of all current touchpoints |
changedTouches | Array<object> | Touch array. The list of touchpoints that triggered this event |
timeStamp | number | Timestamp when the event is triggered |
.onTouchCancel
Listens for touch interruptions/cancellations.
Response object
Field | Type | Description |
touches | Array<object> | Touch array. List of all current touchpoints |
changedTouches | Array<object> | Touch array. The list of touchpoints that triggered this event |
timeStamp | number | Timestamp when the event is triggered |
.offTouchStart
Removes a start‑touch listener. The listener function passed to onTouchStart. If this parameter is not passed, all listener functions will be removed.
Example
const listener = function (res) { console.log(res) }
TTMinis.game.onTouchStart(listener)
TTMinis.game.offTouchStart(listener) // You must pass the same function object used for listening..offTouchMove
Removes a move‑touch listener. The listener function passed to onTouchMove. If this parameter is not passed, all listener functions will be removed.
Example
const listener = function (res) { console.log(res) }
TTMinis.game.onTouchMove(listener)
TTMinis.game.offTouchMove(listener) // You must pass the same function object used for listening..offTouchEnd
Removes an end‑touch listener. The listener function passed to onTouchEnd. If this parameter is not passed, all listener functions will be removed.
Example
const listener = function (res) { console.log(res) }
TTMinis.game.onTouchEnd(listener)
TTMinis.game.offTouchEnd(listener) // You must pass the same function object used for listening..offTouchCancel
Removes a cancel‑touch listener. The listener function passed in by onTouchCancel. If this parameter is not passed, all listener functions will be removed.
Example
const listener = function (res) { console.log(res) }
TTMinis.game.onTouchCancel(listener)
TTMinis.game.offTouchCancel(listener) // You must pass the same function object used for listening.