android - 如何使用 react-native 实现 Word-Link 游戏中使用的滑动手势
问题描述
我正在尝试制作类似于 Word-Link 的游戏。我想在多个字母之间滑动并创建一个单词。我如何在 React-Native 中实现这一点。我的一个想法是使用模式锁定系统,但我仍在发布此查询以查找是否有更好的方法来做到这一点。目前我正在使用 ToucableOpacity 按下按钮并生成单词。[1]:https ://i.stack.imgur.com/z4iKW.jpg
<TouchableOpacity
onPress={() => {
this.addLetters(alpha4[0])
// Alert.alert("A")
box1 = alpha4[0]
this.setState({ box1: box1 })
}}
>
<View style={{ width: 50, height: 50, backgroundColor: 'beige' }}>
<Text style={{ fontSize: 30, fontWeight: 'bold', justifyContent: 'center', textAlignVertical: 'center', textAlign: 'center', borderWidth: 5 }}>{alpha4[0]}</Text>
</View>
</TouchableOpacity>
解决方案
这个 npm 包提供了在 react-native https://www.npmjs.com/package/react-native-swipe-gestures中检测滑动手势的功能
推荐阅读
- java - 根据条件拆分对象集合
- c# - 在 Windows 10 上将 .NET Core 控制台应用程序切换到全屏模式
- amazon-web-services - EC2 实例连接:设置实例连接时出现问题
- javascript - 为什么在 Javascript 中使用 async 而不使用 await?
- sql - 使用 LEFT JOIN 和 ON 语句仅选择最接近的值
- c# - 如何使统一的 Random.Range() 更加随机?
- vim - Vim 光标轨迹
- logging - 哪些层应该记录异常?
- python - Pyplot一一改变颜色不起作用
- java - Datastax Kafka 连接器无法解析 Json 主题