Commit b75c59b4 authored by limingzhe's avatar limingzhe

feat: 首次提交

parent 9f5f5457
No preview for this file type
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test label.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 144,
"height": 144,
"platformSettings": {},
"subMetas": {
"icon": {
"ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 3,
"trimY": 2,
"width": 138,
"height": 141,
"rawWidth": 144,
"rawHeight": 144,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"uuid": "a5403682-07a4-4deb-a36d-3bda737b49df",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.2",
"uuid": "bf7329d2-ac1f-4247-a899-117097ca7c9c",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
export as namespace Play;
declare class EventEmitter<T> {
on<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
on(evt: string, listener: Function): this;
once<K extends keyof T>(event: K, listener: (payload: T[K]) => any): this;
once(evt: string, listener: Function): this;
off<K extends keyof T>(evt: K | string, listener?: Function): this;
emit<K extends keyof T>(evt: K | string, ...args: any[]): boolean;
}
export enum Event {
/** 断开连接 */
DISCONNECTED = 'disconnected',
/** 加入到大厅 */
LOBBY_JOINED = 'lobbyJoined',
/** 大厅房间列表变化 */
LOBBY_ROOM_LIST_UPDATED = 'lobbyRoomListUpdate',
/** 有新玩家加入房间 */
PLAYER_ROOM_JOINED = 'newPlayerJoinedRoom',
/** 有玩家离开房间 */
PLAYER_ROOM_LEFT = 'playerLeftRoom',
/** 玩家活跃属性变化 */
PLAYER_ACTIVITY_CHANGED = 'playerActivityChanged',
/** 主机变更 */
MASTER_SWITCHED = 'masterSwitched',
/** 离开房间 */
ROOM_LEFT = 'roomLeft',
/** 被踢出房间 */
ROOM_KICKED = 'roomKicked',
/** 房间系统属性变化 */
ROOM_SYSTEM_PROPERTIES_CHANGED = 'roomSystemPropertiesChanged',
/** 房间自定义属性变化 */
ROOM_CUSTOM_PROPERTIES_CHANGED = 'roomCustomPropertiesChanged',
/** 玩家自定义属性变化 */
PLAYER_CUSTOM_PROPERTIES_CHANGED = 'playerCustomPropertiesChanged',
/** 自定义事件 */
CUSTOM_EVENT = 'customEvent',
/** 错误事件 */
ERROR = 'error',
}
export enum ReceiverGroup {
/** 其他人(除了自己之外的所有人) */
Others,
/** 所有人(包括自己) */
All,
/** 主机客户端 */
MasterClient,
}
interface CustomProperties {
[key: string]: any;
}
interface CustomEventData {
[key: string]: any;
}
interface ErrorEvent {
code: number;
detail: string;
}
declare interface PlayEvent {
connected: void;
connectFailed: ErrorEvent;
disconnected: void;
lobbyJoined: void;
lobbyLeft: void;
lobbyRoomListUpdate: void;
roomCreated: void;
roomCreateFailed: ErrorEvent;
roomJoined: void;
roomJoinFailed: ErrorEvent;
newPlayerJoinedRoom: {
newPlayer: Player;
};
playerLeftRoom: {
leftPlayer: Player;
};
playerActivityChanged: {
player: Player;
};
masterSwitched: {
newMaster: Player;
};
roomLeft: void;
roomKicked: {
code: number;
msg: string;
};
roomCustomPropertiesChanged: {
changedProps: CustomProperties;
};
roomSystemPropertiesChanged: {
changedProps: CustomProperties;
};
playerCustomPropertiesChanged: {
player: Player;
changedProps: CustomProperties;
};
customEvent: {
eventId: number;
eventData: CustomEventData;
senderId: number;
};
error: ErrorEvent;
}
export class LobbyRoom {
readonly roomName: string;
readonly maxPlayerCount: number;
readonly expectedUserIds: string[];
readonly emptyRoomTtl: number;
readonly playerTtl: number;
readonly playerCount: number;
readonly customRoomPropertiesForLobby: CustomProperties;
}
export class Player {
readonly userId: string;
readonly actorId: number;
readonly isLocal: boolean;
readonly isMaster: boolean;
readonly isActive: boolean;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
}
export class Room {
readonly name: string;
readonly open: boolean;
readonly visible: boolean;
readonly maxPlayerCount: number;
readonly master: Player;
readonly masterId: number;
readonly expectedUserIds: string[];
readonly playerList: Player[];
getPlayer(actorId: number): Player;
setCustomProperties(
properties: CustomProperties,
opts?: {
expectedValues?: CustomProperties;
}
): Promise<void>;
readonly customProperties: CustomProperties;
setOpen(open: boolean): Promise<void>;
setVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
leave(): Promise<void>;
}
export class Client extends EventEmitter<PlayEvent> {
readonly room: Room;
readonly player: Player;
readonly lobbyRoomList: LobbyRoom[];
userId: string;
constructor(opts: {
appId: string;
appKey: string;
userId: string;
ssl?: boolean;
feature?: string;
gameVersion?: string;
playServer?: string;
});
connect(): Promise<Client>;
reconnect(): Promise<Client>;
reconnectAndRejoin(): Promise<Room>;
close(): Promise<void>;
joinLobby(): Promise<void>;
leaveLobby(): Promise<void>;
createRoom(opts?: {
roomName?: string;
roomOptions?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
joinRoom(
roomName: string,
opts?: {
expectedUserIds?: string[];
}
): Promise<Room>;
rejoinRoom(roomName: string): Promise<Room>;
joinOrCreateRoom(
roomName: string,
opts?: {
roomOptions?: Object;
expectedUserIds: string[];
}
): Promise<Room>;
joinRandomRoom(opts?: {
matchProperties?: Object;
expectedUserIds?: string[];
}): Promise<Room>;
matchRandom(
piggybackPeerId: string,
opts?: { matchProperties?: Object; expectedUserIds?: string[] }
): Promise<LobbyRoom>;
setRoomOpen(open: boolean): Promise<void>;
setRoomVisible(visible: boolean): Promise<void>;
setRoomMaxPlayerCount(count: number): Promise<void>;
setRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
clearRoomExpectedUserIds(): Promise<void>;
addRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
removeRoomExpectedUserIds(expectedUserIds: string[]): Promise<void>;
setMaster(newMasterId: number): Promise<void>;
sendEvent(
eventId: number,
eventData?: CustomEventData,
options?: {
receiverGroup?: ReceiverGroup;
targetActorIds?: number[];
}
): Promise<void>;
leaveRoom(): Promise<void>;
kickPlayer(
actorId: number,
opts?: {
code?: number;
msg?: string;
}
): Promise<void>;
pauseMessageQueue(): void;
resumeMessageQueue(): void;
}
export enum CreateRoomFlag {
FixedMaster = 1,
MasterUpdateRoomProperties = 2,
}
export function setAdapters(newAdapters: { WebSocket: Function }): void;
export enum LogLevel {
Debug = 'Debug',
Warn = 'Warn',
Error = 'Error',
}
export function setLogger(logger: {
Debug: (...args: any[]) => any;
Warn: (...args: any[]) => any;
Error: (...args: any[]) => any;
}): void;
export enum PlayErrorCode {
OPEN_WEBSOCKET_ERROR = 10001,
SEND_MESSAGE_STATE_ERROR = 10002,
}
export function registerType<T>(
type: T,
typeId: number,
serializeMethod: (obj: T) => Uint8Array,
deserializeMethod: (bytes: Uint8Array) => T
): void;
export function serializeObject(obj: Object): Uint8Array;
export function deserializeObject(bytes: Uint8Array): Object;
{
"ver": "2.0.0",
"uuid": "bf90aef2-7bcb-4104-a847-44912239338b",
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.8",
"uuid": "72a54dd3-a71e-439e-919d-5034441e90aa",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "cb9fa4ea-66ca-45af-ad31-e445c7b0ef32",
"uuid": "08aeb470-9bb4-4d79-99c3-02ac98aa57c2",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"uuid": "4da8b79a-04e3-4b24-8aec-1f7923a19c6f",
"downloadMode": 0,
"duration": 0.130612,
"duration": 2.088,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d922f027-0050-425d-8ca3-231b12af6099",
"downloadMode": 0,
"duration": 1.044,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "d0746695-78cd-4846-8e2a-09c4deb43818",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "19adfcb4-7656-4e93-a767-842a68e2945f",
"downloadMode": 0,
"duration": 0.9,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "83aa0f59-6a35-4d77-b533-628633c6999e",
"downloadMode": 0,
"duration": 1.008,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "ef22bad2-04ec-4455-b4b8-fa7132a97b4c",
"downloadMode": 0,
"duration": 0.828,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "82267a6f-fb0f-4a2a-8075-1538c80b11e0",
"downloadMode": 0,
"duration": 0.9,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "6f1a94aa-4173-4ce0-bcf1-262464996f9f",
"downloadMode": 0,
"duration": 0.828,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d802d84c-375b-4d11-8ca4-e412fd1ecca3",
"downloadMode": 0,
"duration": 0.936,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "32ecad5a-9530-4f54-bfc4-08279497cfa9",
"downloadMode": 0,
"duration": 0.936,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "4f4a61ae-5e8e-478e-890b-db9efa852e80",
"downloadMode": 0,
"duration": 0.936,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "dd6fc3d1-f2bf-47a2-88de-74785aac56b9",
"downloadMode": 0,
"duration": 0.936,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "9a50c4b9-9644-4ca8-88d0-0a82f28e326c",
"downloadMode": 0,
"duration": 1.08,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "f91ead7e-39ea-4f7f-850f-b0b28d972e01",
"downloadMode": 0,
"duration": 6.048,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8ec9bb43-d74c-49ff-a535-07426bc9f260",
"downloadMode": 0,
"duration": 3.096,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "79c02573-21a9-4b5a-94b9-2291785ab8ef",
"downloadMode": 0,
"duration": 6.516,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "1ec86b52-bc5c-4469-b06d-641bfbf1b99b",
"downloadMode": 0,
"duration": 4.356,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "fef35659-d296-40cf-9583-086dd064265c",
"downloadMode": 0,
"duration": 2.592,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "0853721c-3f55-4eb2-873d-e3081cfadd4b",
"uuid": "9d436a24-95f1-4e7f-b2d3-1457b87a6f61",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.2",
"uuid": "5d8e128a-409d-4c36-98bc-02fb275203e8",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "38431781-6227-44ee-93ec-27e6b9c028c2",
"subMetas": {}
}
\ No newline at end of file
{"name":"mao","imagePath":"mao_tex.png","SubTexture":[{"name":"猫01/影子","x":1,"height":66,"y":343,"width":337},{"name":"猫01/尾巴","x":1,"height":109,"y":188,"width":175},{"name":"猫01/右腿","x":178,"height":117,"y":188,"width":104},{"name":"猫01/左腿","x":1,"height":115,"y":569,"width":64},{"name":"猫01/右手","x":427,"height":122,"y":590,"width":69},{"name":"猫01/左手","x":301,"height":74,"y":590,"width":124},{"name":"猫01伸/左手伸直","x":299,"height":169,"y":1,"width":168},{"name":"猫01伸/右手伸直","x":299,"height":169,"y":172,"width":168},{"name":"猫01/身体","x":340,"height":180,"y":343,"width":122},{"name":"猫01/领带","x":1,"height":156,"y":411,"width":120},{"name":"猫01/右耳","x":155,"height":76,"y":602,"width":90},{"name":"猫01/左耳","x":67,"height":85,"y":602,"width":86},{"name":"猫01/组_1","x":1,"height":185,"y":1,"width":296},{"name":"猫01/右眼","x":1,"height":60,"y":686,"width":59},{"name":"猫01/右眉毛","x":67,"height":5,"y":595,"width":33},{"name":"猫01/左眼","x":247,"height":60,"y":666,"width":59},{"name":"猫01/左眉毛","x":247,"height":12,"y":602,"width":31},{"name":"猫01/眼镜","x":301,"height":63,"y":525,"width":170},{"name":"猫01/胡子","x":123,"height":85,"y":515,"width":176},{"name":"猫01/鼻子","x":67,"height":24,"y":569,"width":28},{"name":"猫01/嘴","x":1,"height":30,"y":299,"width":65},{"name":"猫01/帽子","x":123,"height":102,"y":411,"width":158}],"height":1024,"width":512}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "34a064d5-f50d-4509-b276-7c6248934f28",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "5e2623e4-423c-4193-822f-6d0639133b13",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 512,
"height": 1024,
"platformSettings": {},
"subMetas": {
"mao_tex": {
"ver": "1.0.4",
"uuid": "237cec5a-8188-43c8-b49d-aaf611ec86e3",
"rawTextureUuid": "5e2623e4-423c-4193-822f-6d0639133b13",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7.5,
"offsetY": 138.5,
"trimX": 1,
"trimY": 1,
"width": 495,
"height": 745,
"rawWidth": 512,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5697ceff-d264-43e9-b1e1-0ddd980bb4dc",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
This diff is collapsed.
{
"ver": "1.0.1",
"uuid": "5e3bb085-83a1-41e2-abb7-a2701729e50d",
"subMetas": {}
}
\ No newline at end of file
{"width":1024,"imagePath":"间谍人物40(2)_tex.png","height":1024,"name":"间谍人物40(2)","SubTexture":[{"width":60,"y":773,"height":91,"name":"间谍人物40(2)/脖子_0","x":944},{"width":163,"y":740,"height":193,"name":"间谍人物40(2)/头_0","x":191},{"width":261,"y":838,"height":115,"name":"间谍人物40(2)/帽子_0","x":356},{"width":125,"y":1,"height":242,"name":"间谍人物40(2)/右裤子鞋","x":234},{"width":124,"y":1,"height":218,"name":"间谍人物40(2)/左裤子鞋","x":885},{"width":57,"y":468,"height":328,"name":"间谍人物40(2)/左手_0","x":885},{"width":231,"y":1,"height":490,"name":"间谍人物40(2)/衣服_0","x":1},{"width":103,"y":493,"height":343,"name":"间谍人物40(2)/右手_0","x":376},{"width":82,"y":950,"height":25,"name":"间谍人物40(2)/闭眼","x":885},{"width":82,"y":274,"height":29,"name":"间谍人物40(2)/睁眼_0","x":234},{"width":101,"y":949,"height":65,"name":"间谍人物40(2)/五官_0","x":1},{"width":89,"y":245,"height":27,"name":"间谍人物40(2)/眉毛_0","x":234},{"width":127,"y":935,"height":72,"name":"间谍人物40(2)/衣领","x":191},{"width":58,"y":866,"height":82,"name":"间谍人物40(2)/脖子","x":944},{"width":172,"y":310,"height":163,"name":"间谍人物40(2)/头","x":234},{"width":264,"y":838,"height":113,"name":"间谍人物40(2)/帽子","x":619},{"width":183,"y":493,"height":245,"name":"间谍人物40(2)/右脚","x":191},{"width":107,"y":221,"height":245,"name":"间谍人物40(2)/左脚","x":885},{"width":48,"y":468,"height":303,"name":"间谍人物40(2)/右手","x":944},{"width":188,"y":493,"height":454,"name":"间谍人物40(2)/衣服","x":1},{"width":98,"y":1,"height":307,"name":"间谍人物40(2)/左手","x":361},{"width":55,"y":949,"height":72,"name":"间谍人物40(2)/口袋","x":104},{"width":81,"y":977,"height":18,"name":"间谍人物40(2)/眉毛","x":885},{"width":98,"y":953,"height":65,"name":"间谍人物40(2)/五官","x":619},{"width":73,"y":953,"height":12,"name":"间谍人物40(2)/图层1","x":798},{"width":77,"y":997,"height":19,"name":"间谍人物40(2)/睁眼","x":719}]}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "3ff67ca8-00a4-4dbe-8a61-1845775b301f",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e2f7af48-0bef-4bbd-b494-03c082905f6b",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1024,
"height": 1024,
"platformSettings": {},
"subMetas": {
"间谍人物40(2)_tex": {
"ver": "1.0.4",
"uuid": "61d8541e-cc25-4b86-9ab9-9dd1087b875f",
"rawTextureUuid": "e2f7af48-0bef-4bbd-b494-03c082905f6b",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -7,
"offsetY": 1,
"trimX": 1,
"trimY": 1,
"width": 1008,
"height": 1020,
"rawWidth": 1024,
"rawHeight": 1024,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "20185448-a1ca-4de2-8b37-7bf6cdfccbae",
"uuid": "41f99db4-09c9-451b-82ce-15f53584fb32",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.0",
"uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"uuid": "04322955-77e6-41b8-87d6-a33762408b65",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "20e62cbf-6e87-41fa-a2ad-46089e4108ad",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5f6e6d52-e9c2-495f-b452-6148adf295b3",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
cc.Class({
extends: cc.Component,
properties: {
},
ctor() {
this._timeoutIds = [];
this._intervalIds = [];
this._maxRate = 0;
},
// 生命周期 onLoad
onLoad() {
this.initSize();
},
_designSize: null, // 设计分辨率
_frameSize: null, // 屏幕分辨率
_mapScaleMin: null, // 场景中常用缩放(取大值)
_mapScaleMax: null, // 场景中常用缩放(取小值)
_cocosScale: null, // cocos 自缩放 (较少用到)
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
this._designSize = cc.view.getDesignResolutionSize();
let sx = cc.winSize.width / frameSize.width;
let sy = cc.winSize.height / frameSize.height;
this._cocosScale = Math.min(sx, sy);
sx = frameSize.width / this._designSize.width;
sy = frameSize.height / this._designSize.height;
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
},
// 生命周期 start
async start() {
this.updateLabel('创建房间中');
this.progressTo(0.1, 1);
await this.asyncDelay(1);
this.updateLabel('匹配小伙伴中');
},
async initView() {
this.setMaxPlayerNumber(5);
},
setMaxPlayerNumber(number) {
this._maxPlayerNum = number;
},
addPlayer(name, isSelf, headUrl) {
console.log('name = ' + name);
const layout = cc.find('layout', this.node);
const headNode = cc.instantiate(cc.find('head', this.node));
headNode.x = 0;
headNode.y = 0;
headNode.active = true;
const frameSelf = cc.find('frame_self', headNode);
if (!isSelf) {
frameSelf.opacity = 0;
}
const nameLabel = cc.find('name', headNode);
nameLabel.getComponent(cc.Label).string = name;
const headImg = cc.find('mask/headImg', headNode);
this.loadSpriteByUrl(headImg, headUrl, () => {
const scale = Math.max(
headImg.parent.width / headImg.width,
headImg.parent.height / headImg.height
);
headImg.scale = scale;
});
layout.addChild(headNode);
const rate = Math.min(1, layout.children.length / this._maxPlayerNum);
if (rate == 1) {
this.updateLabel('同步中');
}
this.progressTo(rate, 3);
},
onLoadFinished(func) {
this._onLoadFinishFunc = func;
},
async asyncDelay(time) {
return new Promise((resolve, reject) => {
try {
this._timeoutIds.push(setTimeout(() => {
resolve();
}, time * 1000));
} catch (e) {
reject(e);
}
});
},
updateLabel(str) {
const label = cc.find('label', this.node).getComponent(cc.Label);
if (label.tweenAction) {
label.tweenAction.stop();
}
label.tweenAction = cc.tween(label)
.set({ string: `${str}` })
.delay(0.4)
.set({ string: `${str}.` })
.delay(0.4)
.set({ string: `${str}..` })
.delay(0.4)
.set({ string: `${str}...` })
.delay(0.4)
.union()
.repeatForever()
.start();
},
progressTo(rate, time) {
this._maxRate = Math.max(this._maxRate, rate);
const duration = Math.max(time + this.RandomInt(-1, 1), 1);
const progress = cc.find('progressBar', this.node).getComponent(cc.ProgressBar);
if (progress.tweenAction) {
progress.tweenAction.stop();
}
const easingList = [
'linear',
'quadInOut',
'cubicInOut',
];
progress.tweenAction = cc.tween(progress)
.to(duration, { progress: this._maxRate }, { easing: easingList[this.RandomInt(easingList.length)] })
.call(() => {
if (rate == 1) {
if (this._onLoadFinishFunc) {
this._onLoadFinishFunc();
}
this.node.active = false;
}
})
.start();
},
RandomInt(a, b = 0) {
let max = Math.max(a, b);
let min = Math.min(a, b);
return Math.floor(Math.random() * (max - min) + min);
},
// ------------------------------------------------
loadSpriteByUrl(node, url, cb) {
cc.loader.load({ url }, (err, img) => {
if (!node) {
cb && cb();
}
const spriteFrame = new cc.SpriteFrame(img)
const spr = node.getComponent(cc.Sprite);
spr.spriteFrame = spriteFrame;
if (cb) {
cb();
}
});
},
currentPlayedAudioId: null,
stopCurrentPlayedAudio() {
if (this.currentPlayedAudioId !== null) {
cc.audioEngine.stop(this.currentPlayedAudioId);
this.currentPlayedAudioId = null;
}
},
playEffect(name, cb) {
this.stopCurrentPlayedAudio();
const audioNode = cc.find(`audios/${name}`);
const audioClip = audioNode.getComponent(cc.AudioSource).clip;
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.currentPlayedAudioId = audioId;
if (cb) {
cc.audioEngine.setFinishCallback(audioId, cb);
}
},
playAudioByUrl(audio_url, cb = null) {
if (!audio_url) {
if (cb) {
cb();
}
return;
}
this.stopCurrentPlayedAudio();
cc.assetManager.loadRemote(audio_url.toLowerCase(), (err, audioClip) => {
const audioId = cc.audioEngine.play(audioClip, false, 0.8);
this.currentPlayedAudioId = audioId;
if (cb) {
cc.audioEngine.setFinishCallback(audioId, cb);
}
});
},
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
});
{
"ver": "1.0.8",
"uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"uuid": "9cbb93c2-c40e-49d8-9ed2-870c18809671",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.2.9",
"uuid": "0b657945-1dee-4c7f-afff-51c29fc99d11",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ba450cfd-3160-4047-8205-4d53d42e11af",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.0",
"uuid": "d997af48-a2a8-4d87-b8a7-e9b78f1c1100",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"uuid": "72d6b813-5af7-4076-a7c4-50b3d8cb13cc",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1280,
"height": 720,
"width": 2176,
"height": 1600,
"platformSettings": {},
"subMetas": {
"bg": {
"ver": "1.0.4",
"uuid": "8288e3d4-4c75-4b27-8f01-f7014417f4dd",
"rawTextureUuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"uuid": "b1825854-0f5a-423f-bf20-9e511ba10c03",
"rawTextureUuid": "72d6b813-5af7-4076-a7c4-50b3d8cb13cc",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......@@ -22,10 +22,10 @@
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1280,
"height": 720,
"rawWidth": 1280,
"rawHeight": 720,
"width": 2176,
"height": 1600,
"rawWidth": 2176,
"rawHeight": 1600,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "1.1.0",
"uuid": "3ea86bbe-5e65-4254-ba10-caedf9079ef7",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "6bcae241-34cd-4e29-85b6-22d6e23b55d8",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "point",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1568,
"height": 32,
"platformSettings": {},
"subMetas": {
"progress_bar": {
"ver": "1.0.4",
"uuid": "c33b31eb-6aff-49a7-989b-b3a2fa772fc8",
"rawTextureUuid": "6bcae241-34cd-4e29-85b6-22d6e23b55d8",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1568,
"height": 32,
"rawWidth": 1568,
"rawHeight": 32,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "3f8bedd1-f4e2-46b6-8c1d-bb9e455a76b4",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "point",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1578,
"height": 42,
"platformSettings": {},
"subMetas": {
"progress_bg": {
"ver": "1.0.4",
"uuid": "d1d895b9-8729-49c4-a968-fed148dd979f",
"rawTextureUuid": "3f8bedd1-f4e2-46b6-8c1d-bb9e455a76b4",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 1578,
"height": 42,
"rawWidth": 1578,
"rawHeight": 42,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8cafc419-60ff-47e9-90ba-4a78dd1e9d5a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 280,
"height": 280,
"platformSettings": {},
"subMetas": {
"tx_01": {
"ver": "1.0.4",
"uuid": "3d2a4e59-21f6-4e5f-a4f0-e78926edba56",
"rawTextureUuid": "8cafc419-60ff-47e9-90ba-4a78dd1e9d5a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 280,
"height": 280,
"rawWidth": 280,
"rawHeight": 280,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "3f4deece-30c2-450f-a2df-ddac8cf9d33a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 366,
"height": 336,
"width": 258,
"height": 258,
"platformSettings": {},
"subMetas": {
"1orange": {
"tx_01zw": {
"ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"uuid": "897ff920-a271-4c52-a049-517dcd6ce680",
"rawTextureUuid": "3f4deece-30c2-450f-a2df-ddac8cf9d33a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"offsetY": 0,
"trimX": 0,
"trimY": 1,
"width": 366,
"height": 335,
"rawWidth": 366,
"rawHeight": 336,
"trimY": 0,
"width": 258,
"height": 258,
"rawWidth": 258,
"rawHeight": 258,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "ad038218-ea61-4388-8838-5350212cd28c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 388,
"height": 388,
"platformSettings": {},
"subMetas": {
"tx_xuanzhong": {
"ver": "1.0.4",
"uuid": "48d7c2fc-06cb-443c-baa4-5f5863a84333",
"rawTextureUuid": "ad038218-ea61-4388-8838-5350212cd28c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 388,
"height": 388,
"rawWidth": 388,
"rawHeight": 388,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "e8bd16b0-3804-45a9-a8ca-f52c02224f55",
"uuid": "8a6655c9-de95-40ee-a7fc-2cd9900a6c19",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
This diff is collapsed.
{
"ver": "1.2.9",
"uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"uuid": "3d9cb7a4-7709-4182-b7d9-1be1c526ef5f",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment