Android与2048颤抖游戏的ios之间的滚动差异

问题描述 投票:0回答:1

我试图玩这款2048扑扑游戏。一切对Android都很好,但在iOS上,当我上下滑动以移动集团时,是屏幕在移动……因此无法播放

这里是源代码https://github.com/anuranBarman/2048

以及我认为iOS上的垂直手势存在问题的部分:

  Container(
              height: height,
              child: Stack(
                children: <Widget>[
                  Padding(
                    padding: EdgeInsets.all(10.0),
                    child: GestureDetector(
                      child: GridView.count(
                        primary: false,
                        crossAxisSpacing: 10.0,
                        mainAxisSpacing: 10.0,
                        crossAxisCount: 4,
                        children: getGrid(gridWidth, gridHeight),
                      ),
                      onVerticalDragEnd: (DragEndDetails details) {
                        //primaryVelocity -ve up +ve down
                        if (details.primaryVelocity < 0) {
                          handleGesture(0);
                        } else if (details.primaryVelocity > 0) {
                          handleGesture(1);
                        }
                      },
                      onHorizontalDragEnd: (details) {
                        //-ve right, +ve left
                        if (details.primaryVelocity > 0) {
                          handleGesture(2);
                        } else if (details.primaryVelocity < 0) {
                          handleGesture(3);
                        }
                      },
                    ),
                  ),
                  isgameOver
                      ? Container(
                          height: height,
                          color: Color(MyColor.transparentWhite),
                          child: Center(
                            child: Text(
                              'Game over!',
                              style: TextStyle(
                                  fontSize: 30.0,
                                  fontWeight: FontWeight.bold,
                                  color: Color(MyColor.gridBackground)),
                            ),
                          ),
                        )
                      : SizedBox(),
                  isgameWon
                      ? Container(
                          height: height,
                          color: Color(MyColor.transparentWhite),
                          child: Center(
                            child: Text(
                              'You Won!',
                              style: TextStyle(
                                  fontSize: 30.0,
                                  fontWeight: FontWeight.bold,
                                  color: Color(MyColor.gridBackground)),
                            ),
                          ),
                        )
                      : SizedBox(),    
                ],
              ),
              color: Color(MyColor.gridBackground),
            ),

enter image description here

flutter
1个回答
0
投票

将其添加到您的GridView构造函数:

GridView.count(
    physics: NeverScrollableScrollPhysics(),
    // ...
)
© www.soinside.com 2019 - 2024. All rights reserved.