Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let asset = this.getAssetFromAssets(assetName)
let sourceName = assetName
if (asset.source !== undefined) {
sourceName = asset.source
}
try {
const frameName = this.type + '_' + sourceName
if (!this.spriteFrameExists(frameName)) {
return undefined
}
if (offset === undefined) {
offset = new Geom.Point(0, 0)
}
let layerSprite = new GameObjects.Sprite(this.scene, -Number(asset.x), -Number(asset.y), this.type, frameName).setOrigin(0, 0)
if (this.direction > Directions.FRONT && this.direction < Directions.BEHIND) {
layerSprite.x -= offset.x
}
else {
layerSprite.x += offset.x
}
layerSprite.y += offset.y
if (asset.flipH) {
layerSprite.scaleX = -1
if (frame === undefined) {
frame = animationLayer.frameSequence.frame
}
if (frame.offsets === undefined) {
return new Geom.Point(0, 0)
}
let offset = frame.offsets.offset[direction]
if (offset.x === undefined && offset.y === undefined) {
return new Geom.Point(0, 0)
}
return new Geom.Point(Number(offset.x), Number(offset.y))
}
return new Geom.Point(0, 0)
}
}
let frame = animationLayer.frameSequence.frame[frameId]
if (frame === undefined) {
frame = animationLayer.frameSequence.frame
}
if (frame.offsets === undefined) {
return new Geom.Point(0, 0)
}
let offset = frame.offsets.offset[direction]
if (offset.x === undefined && offset.y === undefined) {
return new Geom.Point(0, 0)
}
return new Geom.Point(Number(offset.x), Number(offset.y))
}
return new Geom.Point(0, 0)
}
private generate(heightmap: number[][]) {
for (let y = 0; y < heightmap.length; y++) {
for (let x = 0; x < heightmap[y].length; x++) {
var coordinates = new Geom.Point(x, y)
var isometricCoordinates = coordinatesToIsometric(coordinates)
var tile = new GameObjects.Image(this.scene, isometricCoordinates.x, isometricCoordinates.y, 'tile')
this.tiles.add(tile)
}
}
this.scene.add.existing(this.tiles)
}
}
}
if (frame.offsets === undefined) {
return new Geom.Point(0, 0)
}
let offset = frame.offsets.offset[direction]
if (offset.x === undefined && offset.y === undefined) {
return new Geom.Point(0, 0)
}
return new Geom.Point(Number(offset.x), Number(offset.y))
}
return new Geom.Point(0, 0)
}