美文网首页
iOS 简易游戏操作控制盘设计

iOS 简易游戏操作控制盘设计

作者: PengCL | 来源:发表于2018-03-04 23:13 被阅读0次

大家无论在玩王者荣耀,还是绝地求生等升级版的游戏时,都会遇到游戏操作控制盘。

基于此,个人开发了一个简易的操作盘,主要包括两个部分:操作控制台背景 和 中间操作圆球。

基于此,定义:consoleBGImageView,放置一张初始Image;定义中间操作圆球为:rotateButton

通过约束条件,来控制rotateButton只能在consoleBGImageView范围内转动

通过UIPanGestureRecognizer添加rotateButton拖动手势,当转动到不同的方向时,修改相应的背景图,这样可以知道转动到哪个方向。

通过如下代码,控制手指触碰的点限制在圆盘内部

-(void)rotateLocation:(CGPoint)pLocation {
    if([self IfYuntaiViewIsIntheBigView:pLocation]){
        self.rotateButton.center = CGPointMake(pLocation.x, pLocation.y);
        
        CGPoint tranPoint = CGPointMake(pLocation.x - centerViewX, pLocation.y - centerViewY);
        ELPCircleConsoleMoveDirection direction = [self determineCameraDirection:tranPoint];
        currentDirection = direction;
    } else {
        CGFloat radius = self.traceView.size.width * 0.5;
        CGPoint pointc = self.consoleBGImageView.center;
        CGPoint changePoint = [self CirclePoint:radius withCenterCircle:pointc withCurrentPoint:pLocation];
        
        self.rotateButton.center = CGPointMake(changePoint.x, changePoint.y);
        
        CGPoint tranPoint = CGPointMake(changePoint.x - centerViewX, changePoint.y - centerViewY);
        ELPCircleConsoleMoveDirection direction = [self determineCameraDirection:tranPoint];
        currentDirection = direction;
    }
    
    CGFloat xValue = fabs(self.rotateButton.centerX - centerViewX);
    CGFloat yValue = fabs(self.rotateButton.centerY - centerViewY);
    
    CGFloat currentRadiusValue = xValue * xValue + yValue * yValue;
    CGFloat bgImgRadiusWith = self.consoleBGImageView.width * 0.5 * 0.5;
    if(currentRadiusValue > bgImgRadiusWith * bgImgRadiusWith * 0.6) {
        [self sendRotateButtonRotateCmd];
    } else {
        [self resumBackgroundImgToNormal];
    }
}

详细代码详见如下链接,如果对你有帮助,麻烦star一个,谢谢。
https://github.com/ElsonPeng/ELPCircleConsoleView

效果图如下:


screenshot.png Simulator Screen Shot - iPhone 8 Plus - 2018-03-04 at 22.43.55.png

相关文章

  • iOS 简易游戏操作控制盘设计

    大家无论在玩王者荣耀,还是绝地求生等升级版的游戏时,都会遇到游戏操作控制盘。 基于此,个人开发了一个简易的操作盘,...

  • 策划笔记

    1 在IOS上发布的手机游戏,要求系统设计的关键内容通过策划配置表格的修改,可以控制部分游戏的功能。 2 系统设计...

  • day11Pythongame应用

    1.pygame事件及鼠标键盘操作 2.简易pygame设计 3.鼠标拖拽图片功能 4.动画效果 5.球球游戏 6...

  • 简易的iOS导航栏颜色渐变方案

    简易的iOS导航栏颜色渐变方案 简易的iOS导航栏颜色渐变方案

  • Android - JoystickView 虚拟手柄,控制盘,

    在一些手机游戏中,玩家可以通过虚拟控制盘来控制游戏角色的行动。无人机和玩具操控App中也有这一类控制盘的应用。 用...

  • 从第一个应用:To Do,纪录总结入门IOS第一课

    纪录自己入门IOS To Do 利用到的IOS知识有: storyboard界面设计 IOS应用生命周期 视图控制...

  • iOS蓝牙

    我的毕业设计是做一个蓝牙操作童车的iOS软件,需求有如下 (1)实现了对童车运动方向、加减速控制。 (2)能够实时...

  • iOS 实现游戏方向转盘或操作盘

    因为时间多哈,特意花时间看看游戏是怎么做的,毕竟也是个未涉足的领域,很多地方都要好好学习。那么现在手游肯定会用到游...

  • 山地摩托车

    这是一款摩托特技竞速游戏,操作简单,但是要得到高分需要技巧。控制摩托车尽快的通过精心设计的道路到达终点。得分越高,...

  • ssh项目实战----java监听器实现权限控制系统和资源获取优

    一、权限控制系统 权限控制系统即用户登录后,如果操作了不能访问的操作,系统将其拦截。权限控制系统设计需求: 系统功...

网友评论

      本文标题:iOS 简易游戏操作控制盘设计

      本文链接:https://www.haomeiwen.com/subject/jefcfftx.html