别踩白块儿4下载ipad,这个游戏采用的什么技术实现的

《别踩白块儿2》类的轻游戏Android开发和普通Android应用开发有
最近在玩《别踩白块儿2》Android版,感觉挺好玩的,它也有普通Android应用底部Tab的设计,那么这种游戏开发和普通Android应用开发有什么区别?PS:以前没有接触过游戏开发。~~~~~~~~~~~~~~~~~~~~~~~~~~~~网友回复:
【《别踩白块儿2》类的轻游戏Android开发和普通Android应用开发有】
请将本文分享给你的朋友:
《别踩白块儿2》类的轻游戏Android开发和普通Android应用开发有 的相关文章
------分隔线----------------------------
北京联盟郑重声明:本文仅代表作者个人观点,与北京联盟无关。其原创性及文中陈述内容未经本站证实,北京联盟对本文及其中全部或者部分内容的真实性、完整性、及时性不作任何保证和承诺,请网友自行核实相关内容。您的当前位置: >
别踩白块儿蛮快操作不可能不可以实现原因
来源:作者:思奇焉者
其实别踩白块儿游戏内容的体验下,小编经常都能听到玩家所说的不要在能够完全驾驭&&甚至超越别踩白块儿的游戏节奏,就会有从最下端的保险区域一直点到上的冲动;其实在这样的解释情况下,小编其实不知道玩家怎么想的,这完全没有必要更没有可能。
作为一款别踩白块儿的游戏,有许多玩家都说游戏像节奏大师,所以其中的节奏性还是很强的,所以玩家除了是没有音乐节奏的玩家才会中二式的赶超其中的节奏,游戏其中的重要内容还是求问、求精准;玩家就容易产生这一赶超大多体现在连续性的黑色色块的调整下。网站已改版,请使用新地址访问:
15WhiteBlock 别踩白块儿的简单源码,实现了 游戏,具有一 参考价值 Java Develop 244万源代码下载- www.pudn.com
&文件名称: 15WhiteBlock& & [
& & & & &&]
&&所属分类:
&&开发工具: Java
&&文件大小: 8 KB
&&上传时间:
&&下载次数: 0
&&提 供 者:
&详细说明:别踩白块儿的简单源码,实现了简单别踩白块儿游戏,具有一定的参考价值-Don t step on the white patch of simple source code, to achieve a simple don t step on white nuggets games, has a certain reference value
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&15WhiteBlock&&............\.classpath&&............\.project&&............\.settings&&............\.........\org.eclipse.jdt.core.prefs&&............\Manifest.mf&&............\bin&&............\...\WhiteBlock1&&............\...\...........\WhiteBlock.class&&............\...\...........\WhiteBlock1.class&&............\src&&............\...\WhiteBlock1&&............\...\...........\WhiteBlock.java&&............\...\...........\WhiteBlock1.java
&输入关键字,在本站244万海量源码库中尽情搜索:Posts - 92,
Articles - 0,
Comments - 12
keep moving
21:37 by 菜鸟Alex, ... 阅读,
先看下效果图片
前几天看到一个游戏叫别踩白块,下载量还挺大几百万了都,下载下来玩了玩看了看,这个游戏还挺简单的.俗话说想一千遍,一万遍不如动手做一遍来的实在.昨晚以及今天白天闲的没事就开搞了,下午六点钟终于搞完.中间也遇到了些没想到的问题,有个难题想了多半个下午,待我一一道来...篇幅较长字体较小希望能耐心看完
代码没有过多的进行封装,只是先实现了基本的功能.一共才200多行代码?注释--只是没来得及集成音乐
用的是collectionViewController全部代码都在.m文件中
对于经常要用到的变量进行了宏定义
ViewController.m
Created by 裴波波 on 16/4/23.
Copyright (C) 2016年 裴波波. All rights reserved.
#import &ViewController.h&
//屏幕宽度
#define kScreenW [UIScreen mainScreen].bounds.size.width
//屏幕高度
#define kScreenH [UIScreen mainScreen].bounds.size.height
//屏幕尺寸
#define kScreenB [UIScreen mainScreen].bounds
#define kLineCount 4
//每行白块个数
#define kCellCount 200 //白块总个数
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *flowL
/** 存储每一行的cell的可变数组 */
@property (nonatomic, strong) NSMutableArray *arrayM;
/** 记录取整索引 */
@property (nonatomic, assign)
/** 初始状态整体竖直偏移高度 */
@property (nonatomic, assign) CGFloat offsetT
/** 每个cell高度 */
@property (nonatomic, assign) CGFloat itemH;
/** 点击黑块计数器 */
@property (nonatomic, assign) int blackC
/** 主界面view */
@property (nonatomic, strong) UIView *mainV
/** 秒表计时器 */
@property (nonatomic, strong) NSTimer *
/** 显示时间的label */
@property (nonatomic, strong) UILabel *lblT
/** 累计用时 */
@property (nonatomic, assign) CGFloat useT
/** 即将消失 */
@property (nonatomic, assign) int displayN
此处的即将消失的意思是:displayNum,由于collectionView每次滑动的时候,cell即将被销毁(干掉)的时候都会调用的方法.但是当程序刚进入初始化的时候也会调用这个方法,所以用一个数字来标记当点击cell 的时候再判断是否漏掉了黑色的块没有点击.如果漏掉了黑色块没有点击 -& 游戏结束
@implementation ViewController
#pragma mark - 懒加载存储每行cell的可遍数组
-(NSMutableArray *)arrayM{
if (_arrayM == nil) {
_arrayM = [NSMutableArray array];
return _arrayM;
#pragma mark - 数据源
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return kCellC
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@&cell& forIndexPath:indexPath];
/** 绑定tag排序用----并没有什么用处 */
cell.tag = indexPath.
/** 先统一设置cell背景色白色 */
cell.backgroundColor = [UIColor whiteColor];
/** 根据脚标每行随机设置一个颜色为黑色的cell */
/** 将每行的cell 4个存入可变数组,获取随机数0-3,根据随机数取脚标让其变黑 */
/** 将cell数组添加到可变数组 */
[self.arrayM addObject:cell];
/** 记录索引 = 3的时候从中随机选择一个cell让其背景色变 黑 */
if (self.idx == 3) {
/** 产生的随机脚标 */
int idxBlcak = arc4random_uniform(4);
UICollectionViewCell * blackCell = self.arrayM[idxBlcak];
blackCell.backgroundColor = [UIColor blackColor];
self.idx ++;
//idx & 3 重置记录索引
if (self.idx & 3) {
self.idx = 0;
//当重置idx的时候 令可变数组arrayM removeAllObject
[self.arrayM removeAllObjects];
用self.arrayM可变数组来保存每一行的cell,再用产生随机数的函数来产生一个0-3的一个随机数,让后让以这个随机数为脚标的 存在 self.arrayM中的cell的颜色变为黑色这样就实现了 每行黑色的版块的随机.
当idx & 3 的时候再重置为0,接着使用
#pragma mark - 代理
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell * cell = [collectionView cellForItemAtIndexPath:indexPath];
/** 点击开始计时 */
if (self.timer == nil) {
self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(addTimeOfUserUse) userInfo:nil repeats:YES];
NSRunLoop * runloop = [NSRunLoop currentRunLoop];
[runloop addTimer:self.timer forMode:NSRunLoopCommonModes];
/** 标记---奠基石系统执行方法didEndDisplayingCell时检测漏掉的黑色 */
self.displayNum = 1;
/** 判断cell颜色为黑色-&变灰 cell为白色 -& 变红 */
/** 如果点击到了黑块计数 */
if (cell.backgroundColor == [UIColor blackColor]) {
cell.tag = 99999; //此行没有什么卵用
cell.backgroundColor = [UIColor grayColor];
self.blackCount ++;
//点击错误提示用户点错并且返回点击黑色块的数量
cell.backgroundColor = [UIColor redColor];
/** 弹出提示框 */
[self showClickError];
/** 停止计时器 */
[self.timer invalidate];
/** 每次点击黑色块让collectionView偏移 - 一个cell的高度 */
/** 滑动到头发生某个事件 */
if (self.collectionView.contentOffset.y == 0) {
//点击滚动
[self.collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionBottom animated:YES];
当点击黑色的版块的时候:1. 要将黑色 -& 灰色 ,然后collectionView向下滑动过点击的cell,也就是最后一行代码执行的方法.之前我用的是点击cell让整体的collectionView的偏移量 - 最小行间距 - 每个cell的高度.但是这样做有bug,就是当你点击cell collectionVIew向下滑动的时候最下面一行4个cell会直接消失,露出背景色,体验很差...然后看官方文档找方法,找到这个滑动的方法,最合适.
此处当点击cell的时候开启一个定时器,类似自动图片轮播器.当点击到的cell不是黑色的版块的时候,计时器停止,记录时间,点击弹框的确定按钮后将时间给了主界面的label来显示用的时间.
self.blackCount点击到的黑色的版块的计数器,游戏结束后统计结果,在弹框显示点击黑色的版块的数量
此时设置self.displayNum = 1;让下面的方法didEndDisplayingCell,,记录cell被移除会调用的方法,判断被移除cell是否包含黑色的cell如果包含了黑色的cell说明玩家漏掉了黑色的cell,然后弹框提醒-&游戏结束
最后判断当偏移量为0的时候停止滚动.
#pragma mark - 将要消失的cell
-(void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
if (cell.backgroundColor == [UIColor blackColor]) {
if (self.displayNum == 1) {
[self showClickError];
[self.timer invalidate];
self.displayNum = 0;
为什么要用self.displayNum来进行点击的时候判断,因为当程序刚启动的时候也会调用此方法,我们不希望当程序启动的时候就调用此方法中的 &弹框& 以及 &停止计时器&,所以要用一个相当于启动器来启动监视黑色cell是否被干掉
#pragma mark - 累加时间,每秒执行60次
-(void)addTimeOfUserUse{
self.useTime += 1.0 / 60;
#pragma mark - 提示错误框
-(void)showClickError{
UIAlertController * alertVc = [UIAlertController alertControllerWithTitle:@&最终结果& message:[NSString stringWithFormat:@&成绩是:%zd个&,self.blackCount] preferredStyle:UIAlertControllerStyleAlert];
/** 确定返回主界面 */
UIAlertAction * action = [UIAlertAction actionWithTitle:@&确定& style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
self.lblTime.text = [NSString stringWithFormat:@&累计用时%f&,self.useTime];
self.blackCount = 0;
self.displayNum = 0;
[UIView animateWithDuration:0.2 animations:^{
self.mainView.alpha = 1;
[alertVc addAction:action];
[self presentViewController:alertVc animated:YES completion:nil];
弹框提醒的同时将点击的黑色的cell的个数呈现到弹框上.同时重置记录点击cell个数的计数器 self.blackCount,以及self.displayNum.
- (void)viewDidLoad {
[super viewDidLoad];
self.collectionView.backgroundColor = [UIColor blueColor];
/** 初始化布局参数 */
[self initFlowLayout];
/** 初始化主界面 */
[self initMainView];
#pragma mark - 初始化主界面
-(void)initMainView{
UIView * mainView = [[UIView alloc] initWithFrame:kScreenB];
self.mainView = mainV
mainView.backgroundColor = [UIColor orangeColor];
[self.view addSubview:mainView];
UIButton * button = [[UIButton alloc] init];
[button setTitle:@&进入& forState:UIControlStateNormal];
button.bounds = CGRectMake(0, 0, 50, 30);
button.backgroundColor = [UIColor blackColor];
button.center = mainView.
[mainView addSubview:button];
[button addTarget:self action:@selector(hideMainView) forControlEvents:UIControlEventTouchUpInside];
//显示游戏时长label
UILabel * lblTime = [[UILabel alloc] init];
lblTime.frame = CGRectMake(0, 0, kScreenW, 200);
self.lblTime = lblT
lblTime.font = [UIFont systemFontOfSize:22];
lblTime.textAlignment = NSTextAlignmentC
[mainView addSubview:lblTime];
#pragma mark - 隐藏主界面进入游戏
-(void)hideMainView{
/** 将计时器重置为nil */
self.timer =
/** 将累计用时重置nil */
self.useTime = 0;
/** 每次进入游戏将偏移量重置 */
CGFloat offset = (kCellCount / kLineCount - 1) * self.flowLayout.minimumLineSpacing + (kCellCount / kLineCount) * self.itemH - kScreenH;
self.offsetTotal =
self.collectionView.contentOffset = CGPointMake(0, offset);
/** 每次进入游戏将红块重置为白块 -& 刷新collectionView */
[self.collectionView reloadData];
[UIView animateWithDuration:0.5 animations:^{
self.mainView.alpha = 0;
#pragma mark - 初始化布局参数
-(void)initFlowLayout{
self.flowLayout.minimumLineSpacing = 1;
self.flowLayout.minimumInteritemSpacing = 0; //cell最小间距
CGFloat itemH = (kScreenH - (kLineCount -1) * self.flowLayout.minimumLineSpacing) / 4;
self.itemH = itemH;
self.flowLayout.itemSize = CGSizeMake((kScreenW / kLineCount) - 1,itemH);
//偏移量 = (行数 - 1) * 行间距 + 行数 * 每个cell高度 - 屏幕高度
CGFloat offset = (kCellCount / kLineCount - 1) * self.flowLayout.minimumLineSpacing + (kCellCount / kLineCount) * itemH - kScreenH;
self.offsetTotal =
self.collectionView.contentOffset = CGPointMake(0, offset);
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.bounces = NO; //取消弹簧效果
self.collectionView.scrollEnabled = NO; //取消滚动
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
写完才明白想了那么多遍没想到会遇到的问题.有想法就动手.
最简单最实用的也就是系统的方法,当cell被干掉的时候调用的方法,直接判断黑色的cell是否被干掉即可.其他没什么难度毕竟就一个collectionView而已.
源代码demo下载地址:19被浏览8,901分享邀请回答1添加评论分享收藏感谢收起77 条评论分享收藏感谢收起}

我要回帖

更多关于 别踩白块儿 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信