mirror of
https://github.com/kirikayakazuto/CocosCreator_ECS
synced 2025-10-30 10:55:48 +00:00
update readme
This commit is contained in:
@@ -82,18 +82,21 @@
|
||||
},
|
||||
{
|
||||
"__id__": 18
|
||||
},
|
||||
{
|
||||
"__id__": 26
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 26
|
||||
"__id__": 34
|
||||
},
|
||||
{
|
||||
"__id__": 27
|
||||
"__id__": 35
|
||||
},
|
||||
{
|
||||
"__id__": 28
|
||||
"__id__": 36
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@@ -698,8 +701,8 @@
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_string": "button",
|
||||
"_N$string": "button",
|
||||
"_string": "add a",
|
||||
"_N$string": "add a",
|
||||
"_fontSize": 20,
|
||||
"_lineHeight": 40,
|
||||
"_enableWrapText": false,
|
||||
@@ -1083,8 +1086,8 @@
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_string": "button",
|
||||
"_N$string": "button",
|
||||
"_string": "add b",
|
||||
"_N$string": "add b",
|
||||
"_fontSize": 20,
|
||||
"_lineHeight": 40,
|
||||
"_enableWrapText": false,
|
||||
@@ -1256,6 +1259,391 @@
|
||||
"handler": "onClick2",
|
||||
"customEventData": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "New Button",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 27
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 32
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 40
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
473.095,
|
||||
245.37,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "85qrRc4bZJc5jmPaLOoN5t"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Background",
|
||||
"_objFlags": 512,
|
||||
"_parent": {
|
||||
"__id__": 26
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 28
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 30
|
||||
},
|
||||
{
|
||||
"__id__": 31
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 40
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "0ekZoSTDRBLICbpC5YU3je"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Label",
|
||||
"_objFlags": 512,
|
||||
"_parent": {
|
||||
"__id__": 27
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 29
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 0,
|
||||
"g": 0,
|
||||
"b": 0,
|
||||
"a": 255
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 100,
|
||||
"height": 40
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_trs": {
|
||||
"__type__": "TypedArray",
|
||||
"ctor": "Float64Array",
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"_eulerAngles": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_is3DNode": false,
|
||||
"_groupIndex": 0,
|
||||
"groupIndex": 0,
|
||||
"_id": "b1O0CAOdZBz5+5gIn3dR5n"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 28
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_string": "debug",
|
||||
"_N$string": "debug",
|
||||
"_fontSize": 20,
|
||||
"_lineHeight": 40,
|
||||
"_enableWrapText": false,
|
||||
"_N$file": null,
|
||||
"_isSystemFontUsed": true,
|
||||
"_spacingX": 0,
|
||||
"_batchAsBitmap": false,
|
||||
"_styleFlags": 0,
|
||||
"_underlineHeight": 0,
|
||||
"_N$horizontalAlign": 1,
|
||||
"_N$verticalAlign": 1,
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 1,
|
||||
"_N$cacheMode": 1,
|
||||
"_id": "6cPxNByvpCFJiTXSiCxOaC"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 27
|
||||
},
|
||||
"_enabled": true,
|
||||
"_materials": [
|
||||
{
|
||||
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
|
||||
}
|
||||
],
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_atlas": null,
|
||||
"_id": "adrDAfICJAQ4XbjieFeAUn"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 27
|
||||
},
|
||||
"_enabled": true,
|
||||
"alignMode": 0,
|
||||
"_target": null,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 100,
|
||||
"_originalHeight": 40,
|
||||
"_id": "d4dYinX5hGWaxVDkLesoz7"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Button",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 26
|
||||
},
|
||||
"_enabled": true,
|
||||
"_normalMaterial": null,
|
||||
"_grayMaterial": null,
|
||||
"duration": 0.1,
|
||||
"zoomScale": 1.2,
|
||||
"clickEvents": [
|
||||
{
|
||||
"__id__": 33
|
||||
}
|
||||
],
|
||||
"_N$interactable": true,
|
||||
"_N$enableAutoGrayEffect": false,
|
||||
"_N$transition": 3,
|
||||
"transition": 3,
|
||||
"_N$normalColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 230,
|
||||
"g": 230,
|
||||
"b": 230,
|
||||
"a": 255
|
||||
},
|
||||
"_N$pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 200,
|
||||
"g": 200,
|
||||
"b": 200,
|
||||
"a": 255
|
||||
},
|
||||
"pressedColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 200,
|
||||
"g": 200,
|
||||
"b": 200,
|
||||
"a": 255
|
||||
},
|
||||
"_N$hoverColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"hoverColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_N$disabledColor": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 120,
|
||||
"g": 120,
|
||||
"b": 120,
|
||||
"a": 200
|
||||
},
|
||||
"_N$normalSprite": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"_N$pressedSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"pressedSprite": {
|
||||
"__uuid__": "e9ec654c-97a2-4787-9325-e6a10375219a"
|
||||
},
|
||||
"_N$hoverSprite": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"hoverSprite": {
|
||||
"__uuid__": "f0048c10-f03e-4c97-b9d3-3506e1d58952"
|
||||
},
|
||||
"_N$disabledSprite": {
|
||||
"__uuid__": "29158224-f8dd-4661-a796-1ffab537140e"
|
||||
},
|
||||
"_N$target": {
|
||||
"__id__": 27
|
||||
},
|
||||
"_id": "749WE4zm1JhpiMAmdyMCeA"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ClickEvent",
|
||||
"target": {
|
||||
"__id__": 2
|
||||
},
|
||||
"component": "",
|
||||
"_componentId": "e1b90/rohdEk4SdmmEZANaD",
|
||||
"handler": "onClick3",
|
||||
"customEventData": ""
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
|
||||
@@ -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