MCPcopy Create free account
hub / github.com/melonjs/melonJS / detectObjectType

Function detectObjectType

packages/melonjs/src/level/tiled/TMXObjectFactory.js:59–78  ·  view source on GitHub ↗
(settings)

Source from the content-addressed store, hash-verified

57 * @ignore
58 */
59export function detectObjectType(settings) {
60 if (settings instanceof TMXLayer) {
61 return "layer";
62 }
63 // check if a factory is registered for this object's class
64 if (typeof settings.class === "string" && factories.has(settings.class)) {
65 return settings.class;
66 }
67 // check if a factory is registered for this object's name
68 if (typeof settings.name === "string" && factories.has(settings.name)) {
69 return settings.name;
70 }
71 if (typeof settings.text === "object") {
72 return "text";
73 }
74 if (typeof settings.tile === "object") {
75 return "tile";
76 }
77 return "shape";
78}
79
80/**
81 * Register a factory function for a given Tiled object type.

Callers 1

createTMXObjectFunction · 0.85

Calls 1

hasMethod · 0.45

Tested by

no test coverage detected