碰撞检测道具拾取 collider.zip
creator碰撞检测的实现和道具拾取功能;碰撞检测系统;三个接口:
onCollisionEnter: function (other, self) // 开始
onCollisionStay: function (other, self) // 持续
onCollisionExit: function (other, self) // 结束
cocos creator实例--使用creator简单实现连连看游戏 | 附代码LLK.zip
cocos creator实例--使用creator简单实现连连看游戏 | 附代码。点击相同的两个动物图案,会消失一个选中框,然后就会消失掉
cocos creator实例--游戏Bad Piggies中的一些物理特性的分析 | 附代码phys.zip
cocos creator实例--游戏Bad Piggies中的一些物理特性的分析 | 附代码;为了学习研究creator的物理特性,只有是从刚体、碰撞、关节等组件的属性来着手。这篇文章取材于Bad Piggies游戏,主要是来分析学习creator的一些物理特性。原文地址https://blog.csdn.net/ccnu027cs/article/details/103958130
cocos creator实例--实现FlappyBird游戏的基本功能 | 附代码FlappyBird.zip
FlappyBird是早期的早IOS上的一款非常受欢迎的像素游戏。
点击屏幕控制小鸟上下飞行;小鸟在飞行的过程中,碰撞到管子就结束游戏,飞过一根管子分数加1;
新版Creator 2.1.2,终于支持 ShaderHelper 了----ShaderHelper2.zip
新版Creator 2.1.2,终于支持 ShaderHelper 了
let
ShaderProperty
=
cc
.
Class
({
name
:
'ShaderProperty'
,
properties
:
{
key
:
''
,
value
:
''
,
}
});
cc
.
Class
({
extends
:
cc
.
Component
,
properties
:
{
effect
:
cc
.
EffectAsset
,
//effect资源
speed
:
0.01
,
//控制动态Shader的time参数
props
:
[
ShaderProperty
],
//shader参数
},
start
()
{
if
(!
this
.
effect
)
{
return
;
}
//获取精灵组件
let
sprite
=
this
.
node
.
getComponent
(
cc
.
Sprite
);
if
(!
sprite
)
{
return
;
}
//实例化一个材质对象
let
material
=
new
cc
.
Material
();
//在材质对象上开启USE_TEXTURE定义
material
.
define
(
'USE_TEXTURE'
,
true
);
//为材质设置effect,也是就绑定Shader了
material
.
effectAsset
=
this
.
effect
;
material
.
name
=
this
.
effect
.
name
;
//将材质绑定到精灵组件上,精灵可以绑定多个材质
//这里我们替换0号默认材质
sprite
.
setMaterial
(
0
,
material
);
//从精灵组件上获取材质,这步很重要,不然没效果
this
.
material
=
sprite
.
getMaterial
(
0
);
//初始化参数
this
.
time
=
0
;
this
.
props
.
forEach
(
item
=>
this
.
material
.
setProperty
(
item
.
key
,
item
.
value
));
},
/**
* 在update事件中更新材质参数
* 不同的Shader这里可能需要重写
*/
update
()
{
if
(!
this
.
material
||
!
this
.
speed
)
{
return
;
}
if
(
this
.
flag
)
{
this
.
time
+=
this
.
speed
;
}
else
{
this
.
time
-=
this
.
speed
;
}
if
(
this
.
time
>=
1.2
)
{
this
.
flag
=
0
;
}
else
if
(
this
.
time
<=
-
0.2
)
{
this
.
flag
=
1
;
}
//更新Shader代码中的time参数
this
.
material
.
setProperty
(
'time'
,
this
.
time
);
},
});
如何用一张图片来实现炫光方块--炫光.zip
如何用一张图片来实现炫光方块
CocosCreator 的节点上的颜色属性对 3D 模型是不起作用的,要想修改模型颜色就要对材质操作,而材质是基于 effect 渲染的。那么怎么改变模型颜色呢?
简单猴子吃香蕉游戏,做项目构建流程定制monkey.zip
简单猴子吃香蕉游戏,做项目构建流程定制
主要介绍游戏玩法,具体实现,参考游戏源码。玩法是:游戏开始后,通过虚拟摇杆控制猴子在屏幕左右方向跳动,屏幕上随机出现香蕉,过一段时间后消失,猴子吃到香蕉得分,如果等到香蕉消失时,猴子仍旧没吃到,则游戏结束。
Label长文本手机上不显示处理longText.zip
Label长文本手机上不显示处理
// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
nodeModule: cc.Node,
nodeContainer: cc.Node,
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
// update (dt) {},
setLongText(longText){
// 界限值
const WORDS_COUNT = 100;
let str = longText;
let left = '';
do{
let index = str.indexOf('\n');
if(index == -1){
break;
}
left = left + str.substring(0, index);
str = str.substring(index);
while(str.length > 0 && str[0] == '\n'){
left = left + str[0];
str = str.substring(1);
}
if(left.length > WORDS_COUNT){
if(left.length >= 1&& left[left.length - 1] == '\n'){
left = left.substring(0, left.length -1);
}
this.addModule(left);
left = '';
}
}while(str.length > WORDS_COUNT);
if(left != ''){
this.addModule(left);
}
if(str != ''){
this.addModule(str);
}
},
addModule(text){
cc.log('##text##', text);
let node = cc.instantiate(this.nodeModule);
node.active = true;
node.getComponent(cc.Label).string = text;
this.nodeContainer.addChild(node);
},
onClick(){
this.setLongText(`
Creator数钱小游戏源码CountMoney.zip
Creator数钱小游戏源码CountMoney.zip
// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
nodeMoney: cc.Node,
nodeGuide: cc.Node,
nodeStart: cc.Node,
txtCount: cc.Label,
txtTime: cc.Label,
nodeMoneyBg: cc.Node,
nodeTimerBg: cc.Node,
nodeSpillMoney: cc.Node,
txtTotal: cc.Label,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.node.on(cc.Node.EventType.TOUCH_START, event => {
this.onTouchStart(event);
});
this.node.on(cc.Node.EventType.TOUCH_MOVE, event => {
this.onTouchMove(event);
});
this.node.on(cc.Node.EventType.TOUCH_END, event => {
this.onTouchEnd(event);
});
this.nodeMoneyBg.zIndex = 10;
this.nodeTimerBg.zIndex = 10;
this.nodeStart.zIndex = 20;
this._touchNode = null;
this._count = 0;
this._isPlaying = false;
},
start () {
},
startGame(){
this._isPlaying = true;
this.nodeStart.active = false;
this.txtTime.string = 10;
this.txtCount.string = 0;
this._count = 0;
this.startTimer();
this.spillMoney();
},
startTimer(){
this.schedule(this.timeCallback, 1);
},
timeCallback(){
let time = parseInt(this.txtTime.string);
time--;
this.txtTime.string = time;
if(time this._touchNode.y){
this._touchNode.y = pos.y;
}
},
onTouchEnd(event){
if(!this._isPlaying){
return;
}
let now = event.getLocation();
let start = event.getStartLocation();
if(now.y - start.y > 10){
let seq = cc.sequence(
cc.spawn(
cc.moveBy(0.3, 0, cc.winSize.height),
cc.scaleTo(0.3, 0.7)
),
cc.removeSelf(),
);
this._touchNode.runAction(seq);
}
this._count++;
this.txtCount.string = `${this._count * 100}`;
},
onClick(){
this.startGame();
},
spillMoney(){
let seq = cc.sequence(
cc.delayTime(0.2),
cc.callFunc( () => {
let x = Math.random() * cc.winSize.width;
x -= cc.winSize.width / 2;
let node = cc.instantiate(this.nodeSpillMoney);
node.active = true;
node.parent = this.nodeSpillMoney.parent;
node.runAction(cc.sequence(
cc.place(x, cc.winSize.height / 2 + node.height / 2),
cc.spawn(cc.moveBy(1, 0, -cc.winSize.height - node.height / 2), cc.rotateBy(1, 1080)),
cc.removeSelf(),
));
}),
);
seq.setTag(0xff);
this.node.runAction(seq.repeatForever());
},
});
Creator口红机实现lipstick_3.zip
Creator口红机实现lipstick_3.zip
// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var DataMgr = require('DataMgr');
var LayerMgr = require('LayerMgr');
cc.Class({
extends: cc.Component,
properties: {
nodePlate: cc.Node, // 板子
nodeTouch: cc.Node, // 触摸节点
nodeLipstick: cc.Node, // 口红位置
prefabLipstick: cc.Prefab, // 口红预制
nodeLipstickContainer: cc.Node, // 总共有多少口红容器
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
let mgr = cc.director.getCollisionManager();
mgr.enabled = true;
// mgr.enabledDebugDraw = true;
// mgr.enabledDrawBoundingBox = true;
},
start () {
this.nodeTouch.getComponent('Touch').setCallback( () => {
this.onTouchCallback();
});
this.reloadUI();
this.startRun();
},
// update (dt) {},
startRun(){
// 顺时针转一圈,再逆时针转一圈,如此反复
this.nodePlate.stopAllActions();
this.nodePlate.rotation = 0;
let seq = cc.sequence(
cc.rotateBy(4, 360).easing(cc.easeIn(1.5)),
cc.rotateBy(4, -360).easing(cc.easeIn(1.5)),
);
this.nodePlate.runAction(seq.repeatForever());
},
/**
* @description: 点击屏幕回调
* @param {type}
* @return:
*/
onTouchCallback(){
// 口红用完了
if(DataMgr.leftLipstick <= 0){
CocosCreator实现动物同化AnimalGame.zip
CocosCreator实现动物同化AnimalGame.zip
let ANI_ROW = 14; //小动物行数/列数
let ANI_TYPE = 14; //小动物种类数
let MAX_COUNT = 36; //最大次数
let __DESIGN_RESOLUTION_WIDTH = 1280;
let __DESIGN_RESOLUTION_HEIGHT = 720;
let lineDir = {
NONE : -1, //空
TOP : 0, //上
BOTTOM : 1, //下
LEFT : 2, //左
RIGHT : 3, //右
}
//音效名称
let sound = {
BG : "sound/pveBg", //BG
BUTTON : "sound/click", //按钮点击音效
COMBO1 : "sound/combo1", //1
COMBO2 : "sound/combo2", //2
COMBO3 : "sound/combo3", //3
COMBO4 : "sound/combo4", //4
GAMEOVER : "sound/over", //结束
GAMEPASS : "sound/pass", //过关
READYGO : "sound/readyGo", //准备
}
cc.Class({
extends: cc.Component,
properties: {
//主界面
menuBg : cc.Node,
startBtn : cc.Node,
//游戏界面
gameBg : cc.Node,
levelText : cc.Label,
scoreText : cc.Label,
bestScoreText : cc.Label,
restTimesText : cc.Label,
aniParentLayer : cc.Node,
aniBtn : {
default: [],
type: cc.Button,
},
tiziSp : cc.Node,
refreshBtn : cc.Node,
readySp : cc.Node,
goSp : cc.Node,
tipText : cc.Node,
//失败层
failLayer : cc.Node,
//过关层
winLayer : cc.Node,
awardText : cc.Label,
//结算层
endLayer : cc.Node,
endScoreText : cc.Label,
againBtn : cc.Node,
exitBtn : cc.Node,
//小动物预制体
aniPrefab : cc.Prefab,
btnImgAtlas : cc.SpriteAtlas,
aniImgAtlas : cc.SpriteAtlas,
},
onLoad: function () {
//初始化界面数据
this.levelText.string = "1";
this.scoreText.string = "0";
let aniBestScore = parseInt(cc.sys.localStorage.getItem("aniBestScore")) || 0;
this.bestScoreText.string = aniBestScore;
this.restTimesText.string = "35";
this.fitNode();
},
//元素适配
fitNode : function(){
let canvasSize = cc.view.getCanvasSize();
let canvasScale = canvasSize.width / canvasSize.height;
// 高的比例
let bMoreHeight = canvasScale < (__DESIGN_RESOLUTION_WIDTH / __DESIGN_RESOLUTION_HEIGHT);
//全屏显示
let allShow = (obj)=>{
if (bMoreHeight) {
obj.width = __DESIGN_RESOLUTION_WIDTH;
obj.height = __DESIGN_RESOLUTION_WIDTH / canvasScale;
} else {
obj.width = __DESIGN_RESOLUTION_HEIGHT * canvasScale;
obj.height = __DESIGN_RESOLUTION_HEIGHT;
}
};
//左对齐
let leftAlign = (obj)=>{
if (!bMoreHeight) {
obj.x = obj.position.x - (__DESIGN_RESOLUTION_HEIGHT * canvasScale - __DESIGN_RESOLUTION_WIDTH) / 2;
} else {
obj.x = obj.position.x;
}
};
//右对齐
let rightAlign = (obj)=>{
if (!bMoreHeight) {
obj.x = obj.position.x + (__DESIGN_RESOLUTION_HEIGHT * canvasScale - __DESIGN_RESOLUTION_WIDTH) / 2;
} else {
obj.x = obj.position.x;
}
};
//上对齐
let topAlign = (obj)=>{
if (bMoreHeight) {
obj.y = obj.position.y + (__DESIGN_RESOLUTION_WIDTH / canvasScale - __DESIGN_RESOLUTION_HEIGHT) / 2;
} else {
obj.y = obj.position.y;
}
};
//下对齐
let bottomAlign = (obj)=>{
if (bMoreHeight) {
obj.y = obj.position.y - (__DESIGN_RESOLUTION_WIDTH / canvasScale - __DESIGN_RESOLUTION_HEIGHT) / 2;
} else {
obj.y = obj.position.y;
}
};
//适配高度
let heightScale = (obj)=>{
let canvasSize = cc.view.getCanvasSize();
let scale = canvasSize.height / __DESIGN_RESOLUTION_HEIGHT;
obj.height = scale * 700;
obj.width = scale * 700;
};
//全屏显示组件
allShow(this.menuBg);
allShow(this.gameBg);
allShow(this.endLayer);
//左对齐组件
leftAlign(this.refreshBtn);
//右对齐组件
rightAlign(this.tiziSp);
rightAlign(this.tipText);
//上对齐组件
topAlign(this.refreshBtn);
topAlign(this.tiziSp);
//下对齐组件
bottomAlign(this.startBtn);
bottomAlign(this.againBtn);
bottomAlign(this.exitBtn);
bottomAlign(this.tipText);
heightScale(this.aniParentLayer);
},
//创建游戏界面
showGameLayer : function(){
//this.playSound(sound.BG, true);
this.gameBg.active = true;
this.readyGoAni();
//随机显示一个背景图
this.changeBgSp();
this.resetGame();
},
//readyGo动画
readyGoAni : function(){
this.playSound(sound.READYGO, false);
this.readySp.active = true;
this.readySp.opacity = 0;
this.readySp.runAction(cc.sequence(cc.fadeIn
Cocos Creator模拟砸金蛋3d旋转效果 | 附代码egg.zip
Cocos Creator模拟砸金蛋3d旋转效果 | 附代码egg.zip
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
const {ccclass, property} = cc._decorator;
@ccclass
export default class Game extends cc.Component {
@property
Count: number = 5;
@property(cc.Prefab)
prefab: cc.Prefab = null;
@property(cc.Node)
nodeParent: cc.Node = null;
private mEggs: cc.Node[] = [];
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
onClick(event, data){
switch(data){
case 'add':{
this.addEggs();
break;
}
case 'move':{
this.moveEggs();
break;
}
case 'stop':{
this.stopMoveEggs();
break;
}
}
}
addEggs(){
if(this.Count <= 0){
return;
}
this.mEggs = [];
const N = 360 / this.Count;
for(let i = 0; i < this.Count; i++){
let egg = cc.instantiate(this.prefab);
let js = egg.getComponent('Egg');
js.setRadian(i * N * Math.PI / 180);
js.updatePos();
egg.parent = this.nodeParent;
this.mEggs.push(egg);
}
}
moveEggs(){
for(let i = 0; i < this.mEggs.length; i++){
this.mEggs[i].getComponent('Egg').setMove(true);
}
}
stopMoveEggs(){
for(let i = 0; i < this.mEggs.length; i++){
this.mEggs[i].getComponent('Egg').setMove(false);
}
}
}
Cocos Creator模拟射箭效果shoot.zip
Cocos Creator模拟射箭效果shoot.zip
// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
txtGrade: cc.Label,
txtTime: cc.Label,
btnStart: cc.Button,
nodeBeat: cc.Node,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this._lefttime = 10;
this._grade = 0;
this.nodeBeat.active = false;
},
start () {
this.nodeBeat.on(cc.Node.EventType.TOUCH_START, event => {
this.nodeBeat.scale = 1.1;
});
this.nodeBeat.on(cc.Node.EventType.TOUCH_END, event => {
this.nodeBeat.scale = 1.0;
this._grade++;
this.txtGrade.string = `面长${this._grade}米`;
});
},
// update (dt) {},
updateGrade(){
if(cc.sys.platform == cc.sys.WECHAT_GAME){
let max = cc.sys.localStorage.getItem('max_grade');
if(max != null && max {
console.log('success', res);
},
faile: res => {
CocosCreator实现的 解救人质 游戏,学会碰撞检测rescue.7z
CocosCreator实现的 解救人质 游戏,学会碰撞检测rescue.7z
// Bullet.js
cc.Class({
extends: cc.Component,
properties: {
mSpeed: 300,
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start() {
var manager = cc.director.getCollisionManager(); // 获取碰撞检测系统
manager.enabled = true;
},
update(dt) { // 设置子弹移动,当超出屏幕范围未发生碰撞时自动销毁
this.node.y += this.mSpeed * dt;
if (this.node.y > 580) {
console.log('超出屏幕范围,子弹销毁!');
this.node.destroy();
}
},
/**
* 当碰撞产生的时候调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionEnter: function (other, self) {
console.log('on collision enter');
if (other.tag == 1) { // 子弹碰到人质时,解救失败!
console.log('解救人质失败!');
var failLabel = this.node.parent.getChildByName('failLabel');
failLabel.active = true;
this.node.destroy();
} else if (other.tag == 2) { // 子弹碰到敌人时,解救成功!
console.log('解救人质成功!');
var successLabel = this.node.parent.getChildByName('successLabel');
successLabel.active = true;
this.node.destroy();
}
},
/**
* 当碰撞产生后,碰撞结束前的情况下,每次计算碰撞结果后调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionStay: function (other, self) {
console.log('on collision stay');
},
/**
* 当碰撞结束后调用
* @param {Collider} other 产生碰撞的另一个碰撞组件
* @param {Collider} self 产生碰撞的自身的碰撞组件
*/
onCollisionExit: function (other, self) {
console.log('on collision exit');
}
});
Creator打地鼠游戏hitmouse.zip
Creator打地鼠游戏hitmouse.zip
// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
mouse: [cc.Node],
hammer: cc.Node,
txtCount: cc.Label,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
var manager = cc.director.getCollisionManager();
manager.enabled = true;
this.count = 0;
this.txtCount.string = this.count;
},
start () {
cc.director.getScheduler().schedule(this.logic, this, 0.5, false);
this.node.on(cc.Node.EventType.TOUCH_START, function(event){
for(let i = 0; i < this.mouse.length; i++){
if(this.mouse[i].opacity == 0){
continue;
}
let parent = this.mouse[i].parent;
let maskPos = parent.parent.convertToWorldSpaceAR(parent.position);
let maskRect = cc.rect(maskPos.x - parent.width / 2 , maskPos.y , parent.width, parent.height);
let mouse = this.mouse[i];
let mousePos = parent.convertToWorldSpaceAR(mouse.position);
let mousRect = cc.rect(mousePos.x - mouse.width / 2, mousePos.y - mouse.height / 2, mouse.width, mouse.height);
let mixRect = new cc.Rect();
maskRect.intersection(mixRect, mousRect);
if(mixRect.contains(event.g
Cocos Creator实现的1024游戏
Cocos Creator实现的1024游戏
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
},
// called every frame, uncomment this function to activate update callback
// update: function (dt) {
// },
});
CocosCreator一步一步实现重力球游戏zhongliText.zip
CocosCreator一步一步实现重力球游戏zhongliText.zip
//碰撞监听脚本
cc.Class({
extends: cc.Component,
properties: {
},
onLoad () {
},
onDestroy () {
},
onBeginContact ( contact, selfCollider, otherCollider){
if(selfCollider.tag == 0 && otherCollider.tag == 0){
cc.log("onBeginContact..."); //碰撞开始
this.gameOver();
}
},
onEndContact (contact, selfCollider, otherCollider){
//cc.log("onEndContact...");//碰撞结束
},
onPreSolve(contact, selfCollider, otherCollider){
//cc.log("onPreSolve...");//碰撞持续,接触时被调用
},
onPostSolve (contact, selfCollider, otherCollider){
//cc.log("onPostSolve...");//碰撞接触更新完后调用,可以获得冲量信息
},
//游戏结束
gameOver (){
if(this.callBack){
this.callBack();
}
},
gameOverCallBack (callBack){
this.callBack = callBack;
},
//隐藏动作
hideBall (){
this.node.runAction(cc.fadeOut(1.0));
},
//显示动作
showBall(){
this.node.opacity = 0;
this.node.runAction(cc.fadeIn(0.5));
}
});
CocosCreator实现左右跳游戏JumpLR.zip
CocosCreator实现左右跳游戏JumpLR.zip
const {ccclass, property} = cc._decorator;
@ccclass
export default class Box extends cc.Component {
@property(cc.Label)
txtNum: cc.Label = null;
private mPrevBox: cc.Node = null;
private mNextBox: cc.Node = null;
private mOffset: number = 0; // [-4,4]
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
setOffset(offset: number){
this.mOffset = offset;
}
getOffset(){
return this.mOffset;
}
setPrev(prev: cc.Node){
this.mPrevBox = prev;
}
getPrev(){
return this.mPrevBox;
}
setNext(next: cc.Node){
this.mNextBox = next;
}
getNext(){
return this.mNextBox;
}
setNum(num: number){
this.txtNum.string = `${num}`;
}
down(y: number){
this.node.runAction(cc.sequence(
cc.moveBy(0.4, 0, y),
cc.callFunc( () => {
NodeMgr.putBox(this.node);
})
));
}
}
大炮英雄Cocos Creator实现GunHero.zip
大炮英雄Cocos Creator实现GunHero
//碰撞监听脚本
cc.Class({
extends: cc.Component,
properties: {
},
onLoad () {
},
onDestroy () {
},
onBeginContact ( contact, selfCollider, otherCollider){
if(selfCollider.tag == 0 && otherCollider.tag == 0){
cc.log("onBeginContact..."); //碰撞开始
this.contactFunction(selfCollider, otherCollider);
}
},
onEndContact (contact, selfCollider, otherCollider){
//cc.log("onEndContact...");//碰撞结束
},
onPreSolve(contact, selfCollider, otherCollider){
//cc.log("onPreSolve...");//碰撞持续,接触时被调用
},
onPostSolve (contact, selfCollider, otherCollider){
//cc.log("onPostSolve...");//碰撞接触更新完后调用,可以获得冲量信息
},
//碰撞监听
contactFunction (selfCollider, otherCollider){
if(this.callBack){
this.callBack(selfCollider, otherCollider);
}
},
contactCallBack (callBack){
this.callBack = callBack;
},
});
Cocos Creator 3D开发入门----CocosCreator3D篮球.zip
Cocos Creator 3D开发入门----CocosCreator3D篮球.zip
import { _decorator, Component, Node, RigidBodyComponent, PhysicMaterial, ColliderComponent } from "cc";
const { ccclass, property } = _decorator;
@ccclass("PhyMat")
export class PhyMat extends Component {
@property
private friction: number = 0; // 摩擦力
@property
private restitution: number = 0; // 弹力
/* class member could be defined like this */
// dummy = '';
/* use `property` decorator if your want the member to be serializable */
// @property
// serializableDummy = 0;
onLoad(): void{
let comps: Array = this.node.getComponents(ColliderComponent) as Array;
let mat = new PhysicMaterial();
mat.friction = this.friction;
mat.restitution = this.restitution;
for(let i = 0; i < comps.length; i++){
comps[i].material = mat;
}
}
start () {
// Your initialization goes here.
}
// update (deltaTime: number) {
// // Your update function goes here.
// }
}
体育类游戏,3D 足球射门 ,Cocos Creator 3D 实现,附源码Creator3D_football.zip
体育类游戏,3D 足球射门 ,Cocos Creator 3D 实现,附源码Creator3D_football.zip
import { _decorator, Component, Node,ColliderComponent,PhysicMaterial } from "cc";
const { ccclass, property } = _decorator;
@ccclass("PhyMat")
export class PhyMat extends Component {
@property
private friction: number = 0; // 摩擦力
@property
private restitution: number = 0; // 弹力
onLoad():void{
let comps: Array = this.node.getComponents(ColliderComponent) as Array;
let mat = new PhysicMaterial();
mat.friction = this.friction;
mat.restitution = this.restitution;
for(let i = 0; i < comps.length; i++){
comps[i].material = mat;
}
}
start () {
// Your initialization goes here.
}
// update (deltaTime: number) {
// // Your update function goes here.
// }
}
cocos creator实现的推箱子游戏,含源码和功能;游戏一共有100关卡。pushBox.zip
cocos creator实现的推箱子游戏,含源码和功能;游戏一共有100关卡。
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
starImg : cc.Node,
itemBg : cc.Node,
levelTxt : cc.Node,
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
},
start () {
},
//--------显示星星数量--------
/**
* @description: 显示星星数量
* @param {boolean} isOpen 是否开启
* @param {starCount} 星星数量
* @param {cc.SpriteAtlas} levelImgAtlas 纹理图
* @param {number} level 关卡
* @return:
*/
showStar : function(isOpen, starCount, levelImgAtlas, level){
this.itemBg.attr({"_level_" : level});
if(isOpen){
this.itemBg.getComponent(cc.Sprite).spriteFrame = levelImgAtlas.getSpriteFrame("pass_bg");
this.starImg.active = true;
this.starImg.getComponent(cc.Sprite).spriteFrame = levelImgAtlas.getSpriteFrame("point" + starCount);
this.levelTxt.opacity = 255;
this.itemBg.getComponent(cc.Button).interactable = true;
}else{
this.itemBg.getComponent(cc.Sprite).spriteFrame = levelImgAtlas.getSpriteFrame("lock");
this.starImg.active = false;
this.levelTxt.opacity = 125;
this.itemBg.getComponent(cc.Button).interactable = false;
}
this.levelTxt.getComponent(cc.Label).string = level;
},
/
入学测试题A卷.docx
JAVA基础班入学考试试卷;考试题目:
本试卷是JAVA基础班入学考试试卷,主要考察JAVA基础前五天大家在入学之前掌握的一个整体情况,本试卷共有40道题,其中有30道是单选,有10道题是多选题,希望大家认真对待
QQ欢乐斗地主-手机游戏-全套源代码
腾讯手机游戏,QQ欢乐斗地主,游戏源码,全套完整的手机游戏源代码,做手游的同学绝对不容错过
package com.tq.tencent.android.sdk;
import com.tq.tencent.android.sdk.cp_config.AppInfoConfig;
public class Domain
{
private static String API_BASE_ENDPOINT = null;
public static final String ROOT_DOMAIN = "openapi.3g.qq.com";
private static final String SCHEME_HTTP = "http://";
public static final String TEST_ROOT_DOMAIN = "openapi.sp0309.3g.qq.com";
public static String getEndPoint()
{
return getQQHallApiEndpoint();
}
public static String getQQHallApiEndpoint()
{
if (API_BASE_ENDPOINT == null)
if (!AppInfoConfig.isTestEnvironment())
break label21;
label21: for (API_BASE_ENDPOINT = "http://openapi.sp0309.3g.qq.com"; ; API_BASE_ENDPOINT = "http://openapi.3g.qq.com")
return API_BASE_ENDPOINT;
}
}
Visual C# 2005(PDF版)
Visual C# 2005,PDF版;适合于初学者;比较基础,适合入门;
Visual Basic(PDF版)
Visual Basic,PDF版本的;适合于初学者;比较基础;
SQL Server2005(PDF版)
SQL Server2005,PDF版本的;适合于初学者适用,比较基础;
PHP技术教程(PDF版)
PHP,PDF版本的;适合初学者适用;比较基础;
Java(PDF版)
Java,PDF版;适合于初学者适用;比较基础;
Java Web开发(PDF版)
Java Web开发,PDF版本的;适合于初学者适用;比较基础全面;
Dreamweaver(PDF版)
DreamweaverPDF版的;适合于初学者;
ASP.NET 2.0(PDF版)
ASP.NET 2.0,PDF版;适合于初学者;初学者教程;
华中科技大学c++课件
15组ppt格式的,华中科技大学的c++课件!
C++经典入门教程(初学者适用)
适合于c++初学者,非常经典的入门教程;
数据挖掘技术及其应用
作为一门交叉学科.数据挖掘融合了
数据库人工智能、统计学等多个钡
域的理论和技术。
基于JAVA的多torrent下载程序
一个基于JAVA的多torrent下载程序,可以手动设置某个torrent的优先权,加入了irc聊天室,增加了一些基本的irc命令,可以看见在线人数和ID,支持多tracker url,对于多tracker发布的torrent可自动切换,并可以手动更改tracker url。
基于JAVA的ICQ系统的设计于实现
ICQ是英文"I seek you "的简称,中文意思是我找你。ICQ最大的功能就是即时信息交流,只要记得对方的号码,上网时可以呼他,无论他在哪里,只要他上网打开ICQ,人们就可以随时交流。ICQ源于以色列特拉维夫的Mirabils公司。该公司成立于1996年7月,也就是在这个时候,互联网上最出名,下载使用人数最多的免费软件ICQ诞生了。可能是其不断增加的用户和广阔的前景以及广泛的应用前景和巨大的市场潜力,Mirabils的ICQ最终被美国在线AOL收购。由于ICQ的成功,推动了ICQ的本土化,就中文的ICQ而言,现在已经越来越多,比如著名的深圳腾迅公司推出的OICQ(现在由于版权问题,已改名为QQ2001),还有由TOM.COM推出的Tomq等,这些软件技术都很好,而且简单易用,成为中国网民最喜欢的通信软件。
基于JAVA的学生成绩管理系统的设计与实现
随着计算机技术的飞速发展和高等教育体制改革的不断深入,传统教育管理方法、手段以及工作效率已不能适应新的发展需要,无法很好地完成教学管理工作。提高教学管理水平的主要途径是更新管理者的思想,增强对管理活动的科学认识。基于Java与SQL server数据库技术建立一个高校成绩管理系统该系统为管理员、学生和教师提供了查询、修改、增加记录、删除等功能,功能比较落齐全,基本上能满足学生和老师的要求。
阳光酒店管理系统源代码
提供普通二星级酒店的必要功能,可动态的进行与房间信息相关的所有操作,对于宾客,可执行散客和团体开单两种方式,可为宾客预定房间,可为不同的宾客设置不能种类房间的折扣及其优惠设置,本系统可动态显示当前所有房间的信息。
ASP编程技术-COMMAND对象的属性SQL的存储过程
ASP编程技术-COMMAND对象的属性SQL的存储过程