MCPcopy Index your code
hub / github.com/4ian/GDevelop / update

Method update

Extensions/TileMap/JsExtension.js:1940–2031  ·  view source on GitHub ↗

* This is called to update the PIXI object on the scene editor

()

Source from the content-addressed store, hash-verified

1938 * This is called to update the PIXI object on the scene editor
1939 */
1940 update() {
1941 const object = gd.castObject(
1942 this._associatedObjectConfiguration,
1943 gd.ObjectJsImplementation
1944 );
1945
1946 const tilemapAtlasImage = object.content.tilemapAtlasImage;
1947 const tilemapJsonFile = object.content.tilemapJsonFile;
1948 const tilesetJsonFile = object.content.tilesetJsonFile;
1949 const layerIndex = object.content.layerIndex;
1950 const levelIndex = object.content.levelIndex;
1951 const displayMode = object.content.displayMode;
1952
1953 if (
1954 tilemapAtlasImage !== this._tilemapAtlasImage ||
1955 tilemapJsonFile !== this._tilemapJsonFile ||
1956 tilesetJsonFile !== this._tilesetJsonFile ||
1957 layerIndex !== this._layerIndex ||
1958 levelIndex !== this._levelIndex ||
1959 displayMode !== this._displayMode
1960 ) {
1961 this._tilemapAtlasImage = tilemapAtlasImage;
1962 this._tilemapJsonFile = tilemapJsonFile;
1963 this._tilesetJsonFile = tilesetJsonFile;
1964 this._layerIndex = layerIndex;
1965 this._levelIndex = levelIndex;
1966 this._displayMode = displayMode;
1967 this.updateTileMap();
1968 }
1969
1970 if (this._instance.hasCustomSize()) {
1971 this._pixiObject.scale.x = this.getCustomWidth() / this.width;
1972 this._pixiObject.scale.y = this.getCustomHeight() / this.height;
1973 } else {
1974 this._pixiObject.scale.x = 1;
1975 this._pixiObject.scale.y = 1;
1976 }
1977
1978 // Place the center of rotation in the center of the object. Because pivot position in Pixi
1979 // is in the **local coordinates of the object**, we need to find back the original width
1980 // and height of the object before scaling (then divide by 2 to find the center)
1981 const originalWidth = this.width;
1982 const originalHeight = this.height;
1983 this._pixiObject.pivot.x = originalWidth / 2;
1984 this._pixiObject.pivot.y = originalHeight / 2;
1985
1986 // Modifying the pivot position also has an impact on the transform. The instance (X,Y) position
1987 // of this object refers to the top-left point, but now in Pixi, as we changed the pivot, the Pixi
1988 // object (X,Y) position refers to the center. So we add an offset to convert from top-left to center.
1989 this._pixiObject.x =
1990 this._instance.getX() +
1991 this._pixiObject.pivot.x * this._pixiObject.scale.x;
1992 this._pixiObject.y =
1993 this._instance.getY() +
1994 this._pixiObject.pivot.y * this._pixiObject.scale.y;
1995
1996 // Rotation works as intended because we put the pivot in the center
1997 this._pixiObject.rotation = RenderedInstance.toRad(

Callers 1

constructorMethod · 0.95

Calls 14

updateTileMapMethod · 0.95
updatePixiTileMapMethod · 0.95
getOpacityMethod · 0.65
hasCustomSizeMethod · 0.45
getCustomWidthMethod · 0.45
getCustomHeightMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
toRadMethod · 0.45
getAngleMethod · 0.45
maxMethod · 0.45
getLayersMethod · 0.45

Tested by

no test coverage detected