体育类游戏,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.
// }
}
1