mirror of
https://github.com/kirikayakazuto/CocosCreator_ECS
synced 2025-10-30 10:55:48 +00:00
update readme
This commit is contained in:
@@ -59,7 +59,12 @@ export default class RoleEventProcess extends EventProcess {
|
||||
break;
|
||||
|
||||
case EventType.GraphicsDraw:
|
||||
this._graphicsDraw(event as EventGraphicsDraw);
|
||||
if(cc.debug.isDisplayStats()) {
|
||||
this._graphicsDraw(event as EventGraphicsDraw);
|
||||
}else {
|
||||
this._graphicsDraw(null);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@@ -76,7 +81,7 @@ export default class RoleEventProcess extends EventProcess {
|
||||
}
|
||||
|
||||
private _graphicsDraw(event: EventGraphicsDraw) {
|
||||
if(event.points.length <= 0) {
|
||||
if(!event || event.points.length <= 0) {
|
||||
this.graphics.clear();
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ export class ComMovable {
|
||||
public speed = 0;
|
||||
public points: cc.Vec2[] = [];
|
||||
public pointIdx = 0;
|
||||
|
||||
public keepDir = false;
|
||||
|
||||
public speedDirty = false;
|
||||
}
|
||||
@@ -23,7 +23,13 @@ export class SysAttack extends ECSSystem {
|
||||
}
|
||||
/** */
|
||||
public onEntityLeave(world: ECSWorld, entity: number): void {
|
||||
|
||||
let filter = world.getFilter(FILTER_ATTACKABLE);
|
||||
// 判断当前monitor是否
|
||||
filter.entities.forEach((value: boolean, otherEntity: number) => {
|
||||
let comBeAttacked = world.getComponent(otherEntity, ComBeAttacked);
|
||||
if(!comBeAttacked) return ;
|
||||
if(comBeAttacked.attacker == entity) comBeAttacked.attacker = -1;
|
||||
});
|
||||
}
|
||||
/** 更新 */
|
||||
public onUpdate(world: ECSWorld, dt: number): void {
|
||||
|
||||
@@ -19,9 +19,18 @@ const FILTER_NODE_EVENT = GenFillterKey([ComCocosNode, ComTransform]);
|
||||
export class SysCocosView extends ECSSystem implements ITouchProcessor {
|
||||
|
||||
onTouchStart(worldPos: cc.Vec2, world: ECSWorld): boolean {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
onTouchMove(worldPos: cc.Vec2, world: ECSWorld): void {
|
||||
|
||||
}
|
||||
|
||||
onTouchCancel(worldPos: cc.Vec2, world: ECSWorld): void {
|
||||
|
||||
}
|
||||
|
||||
onAdd(world: ECSWorld) {
|
||||
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ export class SysMonitor extends ECSSystem {
|
||||
/** */
|
||||
public onEntityLeave(world: ECSWorld, entity: number): void {
|
||||
let filter = world.getFilter(FILTER_MONITOR);
|
||||
// 判断当前monitor是否
|
||||
filter.entities.forEach((value: boolean, otherEntity: number) => {
|
||||
// 判断当前monitor是否
|
||||
filter.entities.forEach((value: boolean, otherEntity: number) => {
|
||||
let comMonitor = world.getComponent(otherEntity, ComMonitor);
|
||||
if(!comMonitor) return ;
|
||||
for(let i=comMonitor.others.length-1; i>=0; i--) {
|
||||
@@ -60,12 +60,6 @@ export class SysMonitor extends ECSSystem {
|
||||
let _check = (com: ComTransform) => {
|
||||
return (a.sub(cc.v2(com.x, com.y)).len() < comMonitor.aroundLen || isInTriangle(cc.v2(com.x, com.y), a, b, c) || isInTriangle(cc.v2(com.x, com.y), b, c, d))
|
||||
}
|
||||
// for(let i=comMonitor.others.length-1; i>=0; i--) {
|
||||
// const com = world.getComponent(comMonitor.others[i], ComTransform);
|
||||
// if(!com || !_check(com)) {
|
||||
// comMonitor.others.splice(i, 1);
|
||||
// }
|
||||
// }
|
||||
|
||||
if(comMonitor.others.indexOf(otherEntity) == -1 && _check(comTransOther)) {
|
||||
comMonitor.others.push(otherEntity);
|
||||
|
||||
@@ -28,6 +28,8 @@ export default class Main extends cc.Component {
|
||||
|
||||
this.regiestTouchEvent();
|
||||
|
||||
//this.regiestTouchHandler();
|
||||
|
||||
}
|
||||
|
||||
onClick1() {
|
||||
@@ -38,6 +40,10 @@ export default class Main extends cc.Component {
|
||||
this.ecsController.createRoleEntity("Cyborg");
|
||||
}
|
||||
|
||||
onClick3() {
|
||||
cc.debug.setDisplayStats(!cc.debug.isDisplayStats());
|
||||
}
|
||||
|
||||
protected update(dt: number): void {
|
||||
if(this._world) this._world.update(dt);
|
||||
}
|
||||
@@ -54,14 +60,20 @@ export default class Main extends cc.Component {
|
||||
this._touchHandler[i].onTouchStart(e.getLocation(), this._world);
|
||||
}
|
||||
}
|
||||
private _onTouchMove() {
|
||||
|
||||
private _onTouchMove(e: cc.Event.EventTouch) {
|
||||
for(let i = 0; i < this._touchHandler.length; i++) {
|
||||
this._touchHandler[i].onTouchMove(e.getLocation(), this._world);
|
||||
}
|
||||
}
|
||||
private _onTouchEnd() {
|
||||
|
||||
private _onTouchEnd(e: cc.Event.EventTouch) {
|
||||
for(let i = 0; i < this._touchHandler.length; i++) {
|
||||
this._touchHandler[i].onTouchEnd(e.getLocation(), this._world);
|
||||
}
|
||||
}
|
||||
private _onTouchCancel() {
|
||||
|
||||
private _onTouchCancel(e: cc.Event.EventTouch) {
|
||||
for(let i = 0; i < this._touchHandler.length; i++) {
|
||||
this._touchHandler[i].onTouchCancel(e.getLocation(), this._world);
|
||||
}
|
||||
}
|
||||
|
||||
public regiestTouchHandler(handler: ITouchProcessor) {
|
||||
|
||||
Reference in New Issue
Block a user