/*
* Game4Key.cpp
*
* Created on: 2013-9-11
* Author: song
*/
#include "Game4Key.h"
#include "SimpleAudioEngine.h"
#include "HelloWorldScene.h"
#include <stdlib.h>
USING_NS_CC;
using namespace CocosDenshion;
using namespace cocos2d::extension;
CCScene* Game4Key::scene() {
CCScene *scene = CCScene::create();
Game4Key *layer = Game4Key::create();
scene->addChild(layer);
return scene;
}
bool Game4Key::init() {
if (!CCLayer::init()) {
return false;
}
setTouchEnabled(true);
visibleSize = CCDirector::sharedDirector()->getVisibleSize();
origin = CCDirector::sharedDirector()->getVisibleOrigin();
this->mp3Seconds = 148;
this->currentSeconds = 0;
//音符出生坐标:等边直角三角形的顶点
bornx = origin.x + visibleSize.width / 2;
//高度等于二分之一根号三乘边长
borny = origin.y + sqrtf(3) / 2 * (visibleSize.width);
perKeyW = visibleSize.width / 4;
perNoteBottom_X = perKeyW;
//音符下落的速度
speed = 1;
this->HP = 100;
this->lastHP = 100;
this->score = 0;
key1Rect =
CCRectMake(origin.x,origin.y,origin.x+perKeyW,origin.y+visibleSize.height/2);
key2Rect =
CCRectMake(origin.x+perKeyW,origin.y,origin.x+perKeyW,origin.y+visibleSize.height/2);
key3Rect =
CCRectMake(origin.x+perKeyW*2,origin.y,origin.x+perKeyW,origin.y+visibleSize.height/2);
key4Rect =
CCRectMake(origin.x+perKeyW*3,origin.y,origin.x+perKeyW,origin.y+visibleSize.height/2);
//场景及返回按钮
CCSprite* pSprite = CCSprite::create("song/andy/andy.png");
//节奏大师按键场景
CCSprite* panlGameSprite = CCSprite::createWithSpriteFrameName(
"panl_game.png");
CCSprite* panl4KSprite = CCSprite::createWithSpriteFrameName("panl_4k.png");
CCSprite* top = CCSprite::createWithSpriteFrameName("top.png");
CCSprite* lSide = CCSprite::createWithSpriteFrameName("b_side.png");
CCSprite* rSide = CCSprite::createWithSpriteFrameName("b_side.png");
CCSprite* sider_1 = CCSprite::createWithSpriteFrameName("b_sider.png");
CCSprite* sider_2 = CCSprite::createWithSpriteFrameName("b_sider.png");
CCSprite* sider_3 = CCSprite::createWithSpriteFrameName("b_sider.png");
pSprite->setPosition(
ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(pSprite, 0);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create("CloseNormal.png",
"CloseSelected.png", this, menu_selector(Game4Key::menuCallback));
pCloseItem->setPosition(
ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
visibleSize.height - pCloseItem->getContentSize().height/2));
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 10);
top->setAnchorPoint(CCPointZero);
top->setPosition(
ccp(origin.x,origin.y+visibleSize.height-top->getContentSize().height));
panl4KSprite->setAnchorPoint(CCPointMake(0.5,1));
panlGameSprite->setAnchorPoint(CCPointMake(0.5,1));
panlGameSprite->setPosition(
ccp(origin.x+visibleSize.width/2,origin.y+visibleSize.height));
this->addChild(panlGameSprite, 1);
panl4KSprite->setPosition(
ccp(origin.x+visibleSize.width/2,origin.y+visibleSize.height-panlGameSprite->getContentSize().height+1));
this->addChild(panl4KSprite, 2);
this->addChild(top, 5);
//顶点出生音符宽度;
float bornPerx = panlGameSprite->getContentSize().width / 8 / 4;
float tleftx = origin.x + visibleSize.width / 2 - 1.5 * bornPerx;
float trightx = tleftx + 4 * bornPerx;
bornNotePos1 = CCPointMake(tleftx,origin.y+visibleSize.height);
bornNotePos2 = CCPointMake(tleftx+bornPerx,origin.y+visibleSize.height);
bornNotePos3 = CCPointMake(tleftx+2*bornPerx,origin.y+visibleSize.height);
bornNotePos4 = CCPointMake(trightx,origin.y+visibleSize.height);
//内角度数
float ndu = atan(
(panl4KSprite->getContentSize().height / 3
+ panlGameSprite->getContentSize().height)
/ (panl4KSprite->getContentSize().width / 2 - 2 * bornPerx))
* 180 / 3.14;
lSide->setAnchorPoint(CCPointMake(1,0));
lSide->setPosition(
ccp(origin.x,origin.y+panl4KSprite->getContentSize().height/3*2));
lSide->setRotation(90 - ndu);
this->addChild(lSide, 4);
rSide->setAnchorPoint(CCPointMake(0,0));
rSide->setPosition(
ccp(origin.x+visibleSize.width,origin.y+panl4KSprite->getContentSize().height/3*2));
rSide->setRotation(-(90 - ndu));
this->addChild(rSide, 4);
float perns = (panlGameSprite->getContentSize().width
- panl4KSprite->getContentSize().height / 3 * 2) / 4;
float nndu = atan(
(perns - bornPerx) / panlGameSprite->getContentSize().height) * 180
/ 3.14;
sider_1->setAnchorPoint(CCPointMake(0.5,0));
sider_2->setAnchorPoint(CCPointMake(0.5,0));
sider_3->setAnchorPoint(CCPointMake(0.5,0));
sider_2->setPosition(
ccp(origin.x+visibleSize.width/2+1,origin.y+panl4KSprite->getContentSize().height));
sider_1->setPosition(
ccp(sider_2->getPosition().x-perns+1,sider_2->getPosition().y));
sider_3->setPosition(
ccp(sider_2->getPosition().x+perns+1,sider_2->getPosition().y));
sider_1->setRotation(nndu);
sider_3->setRotation(-nndu);
this->addChild(sider_2, 4);
this->addChild(sider_1, 4);
this->addChild(sider_3, 4);
draw1 = CCDrawNode::create();
draw2 = CCDrawNode::create();
draw3 = CCDrawNode::create();
draw4 = CCDrawNode::create();
addChild(draw1, 4);
addChild(draw2, 4);
addChild(draw3, 4);
addChild(draw4, 4);
star1[0] =
ccp(origin.x+visibleSize.width/2-2*bornPerx,origin.y+visibleSize.height);
star1[1] =
ccp(origin.x+visibleSize.width/2-2*perns,origin.y+panl4KSprite->getContentSize().height);
star1[2] =
ccp(origin.x+visibleSize.width/2-perns-1,origin.y+panl4KSprite->getContentSize().height);
star1[3] =
ccp(origin.x+visibleSize.width/2-bornPerx-1,origin.y+visibleSize.height);
star2[0] =
ccp(origin.x+visibleSize.width/2-bornPerx+1,origin.y+visibleSize.height);
star2[1] =
ccp(origin.x+visibleSize.width/2-perns+2,origin.y+panl4KSprite->getContentSize().height);
star2[2] =
ccp(origin.x+visibleSize.width/2-2,origin.y+panl4KSprite->getContentSize().height);
star2[3] = ccp(origin.x+visibleSize.width/2-1,origin.y+visibleSize.height);
star3[0] = ccp(origin.x+visibleSize.width/2+1,origin.y+visibleSize.height);
star3[1] =
ccp(origin.x+visibleSize.width/2+2,origin.y+panl4KSprite->getContentSize().height);
star3[2] =
ccp(origin.x+visibleSize.width/2+perns-2,origin.y+panl4KSprite->getContentSize().height);
star3[3] =
ccp(origin.x+visibleSize.width/2+bornPerx-1,origin.y+visibleSize.height);
star4[0] =
ccp(origin.x+visibleSize.width/2+bornPerx+1,origin.y+visibleSize.height);
star4[1] =
ccp(origin.x+visibleSize.width/2+perns+3,origin.y+panl4KSprite->getContentSize().height);
star4[2] =
ccp(origin.x+visibleSize.width/2+2*perns,origin.y+panl4KSprite->getContentSize().height);
star4[3] =
ccp(origin.x+visibleSize.width/2+2*bornPerx,origin.y+visibleSize.height);
// draw1->clear();
CCBlink* lsideActin = CCBlink::create(10, 10);
CCBlink* rsideActin = CCBlink::create(10, 10);
lSide->runAction(
CCRepeatForever::create(CCSequence::create(lsideActin, NULL)));
rSide->runAction(
CCRepeatForever::create(CCSequence::create(rsideActin, NULL)));
//按键精灵
bottomButton0_1 = CCSprite::createWithSpriteFrameName(
"button_4key_0_1.png");
bottomButton0_2 = CCSprite::createWithSpriteFrameName(
"button_4key_0_2.png");
bottomButton0_3 = CCSprite::createWithSpriteFrameName(
"button_4key_0_3.png");
bottomButton0_4 = CCSprite::createWithSpriteFrameName(
"button_4key_0_4.png");
bottomButton1_1 = CCSprite::createWithSpriteFrameName(
"button_4key_1_1.png");
bottomButton1_2 = CCSprite::createWithSpriteFrameName(
"button_4key_1_2.png");
bottomButton1_3 = CCSprite::createWithSpriteFrameName(
"button_4key_1_3.png");
bottomButton1_4 = CCSprite::createWithSpriteFrameNa
没有合适的资源?快使用搜索试试~ 我知道了~
Android应用源码之节奏大师.zip项目安卓应用源码下载
共49个文件
png:22个
plist:6个
h:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 146 浏览量
2022-03-08
16:36:22
上传
评论
收藏 6.56MB ZIP 举报
温馨提示
Android应用源码之节奏大师.zip项目安卓应用源码下载Android应用源码之节奏大师.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
Android应用源码之节奏大师.zip (49个子文件)
Android应用源码之节奏大师
Android应用源码之节奏大师
Resources
.gitignore 43B
960_panle.png 327KB
development.icf 13KB
960_panle.plist 3KB
ipad
CloseSelected.png 13KB
CloseNormal.png 17KB
HelloWorld.png 251KB
background.png 879KB
app.icf 510B
iphone
CloseSelected.png 6KB
CloseNormal.png 7KB
HelloWorld.png 156KB
music
mode_select_02.wav 190KB
music_select_01.wav 249KB
title_bgm.mp3 1008KB
anim
key_press.png 283KB
key_press.ExportJson 8KB
key_press.plist 4KB
score.plist 25KB
score.png 161KB
fonts
jinscore.plist 425B
Marker Felt.ttf 25KB
jinscore.png 9KB
futura-48.png 174KB
futura-48.fnt 12KB
CloseSelected.png 6KB
ipadhd
CloseSelected.png 30KB
CloseNormal.png 39KB
HelloWorld.png 531KB
images
fire.png 722B
CloseNormal.png 7KB
song
andy
andy.png 171KB
andy_5k_nm.imd 6KB
andy_title_hd.png 13KB
andy.mp3 2.2MB
andy_4k_ez.imd 4KB
background.plist 27KB
HelloWorld.png 156KB
button
button.png 54KB
button.plist 8KB
Classes
Game4Key.cpp 21KB
AppMacros.h 3KB
AppDelegate.h 955B
HelloWorldScene.h 1KB
HelloWorldScene.cpp 4KB
AppDelegate.cpp 3KB
VisibleRect.cpp 2KB
Game4Key.h 2KB
VisibleRect.h 551B
共 49 条
- 1
资源评论
yxkfw
- 粉丝: 77
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功