Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #17484: 修复tsx文件对象层自定义属性读取错误 #17486

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cocos/tiledmap/tiled-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import { HorizontalTextAlignment, VerticalTextAlignment } from '../2d/components/label';
import { Texture2D } from '../asset/assets';

export type PropertiesInfo = { [key: string]: number | string };

Check failure on line 31 in cocos/tiledmap/tiled-types.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Use an `interface` instead of a `type`
export type TiledAnimationType = Map<GID, TiledAnimation>;

export interface TiledAnimation {
Expand Down Expand Up @@ -378,7 +378,7 @@

collection = false;

rectForGID (gid_: MixedGID | GID, result?: TiledGrid): Rect | TiledGrid {

Check failure on line 381 in cocos/tiledmap/tiled-types.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Union type constituent is duplicated with MixedGID
const rect = result || new Rect(0, 0, 0, 0);
rect.width = this._tileSize.width;
rect.height = this._tileSize.height;
Expand Down Expand Up @@ -441,6 +441,7 @@
}

export interface TMXObject {
properties: PropertiesInfo;
id: number | string;
name: string;
width: number;
Expand Down
4 changes: 2 additions & 2 deletions cocos/tiledmap/tmx-xml-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

function getPropertyList (node: Element, map?: PropertiesInfo): PropertiesInfo {
const res: any[] = [];
const properties = node.getElementsByTagName('properties');
const properties = Array.from(node.getElementsByTagName('properties')).filter(element => element.parentNode === node);

Check failure on line 92 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected parentheses around arrow function argument
for (let i = 0; i < properties.length; ++i) {
const property = properties[i].getElementsByTagName('property');
for (let j = 0; j < property.length; ++j) {
Expand All @@ -105,13 +105,13 @@

let value = element.getAttribute('value');
if (type === 'int') {
value = parseInt(value);

Check failure on line 108 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
} else if (type === 'float') {
value = parseFloat(value);

Check failure on line 110 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
} else if (type === 'bool') {
value = value === 'true';
} else if (type === 'color') {
value = strToColor(value);

Check failure on line 114 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
}

map![name] = value;
Expand Down Expand Up @@ -204,8 +204,8 @@

protected _imageLayerSPF: { [key: string]: SpriteFrame } | null = null;

constructor (tmxFile: string, tsxContentMap: { [key: string]: string }, spfTexturesMap: { [key: string]: SpriteFrame },

Check failure on line 207 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected newline after '('

Check failure on line 207 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected newline between arguments/params

Check failure on line 207 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected newline between arguments/params
textureSizes: { [key: string]: Size }, imageLayerTextures: { [key: string]: SpriteFrame }) {

Check failure on line 208 in cocos/tiledmap/tmx-xml-parser.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected newline between arguments/params
this.initWithXML(tmxFile, tsxContentMap, spfTexturesMap, textureSizes, imageLayerTextures);
}

Expand Down Expand Up @@ -945,7 +945,7 @@

objectProp.rotation = parseFloat(selObj.getAttribute('rotation')!) || 0;

getPropertyList(selObj, objectProp as any);
objectProp.properties = getPropertyList(selObj);

// visible
const visibleAttr = selObj.getAttribute('visible');
Expand Down
Loading