mirror of
https://github.com/billsonnn/nitro-renderer.git
synced 2025-02-18 19:02:35 +01:00
Another fix for busted hit detection
This commit is contained in:
parent
cbc6b3f25c
commit
56e66cb96b
@ -78,23 +78,10 @@ export class ExtendedSprite extends Sprite
|
|||||||
|
|
||||||
if(!texture || !baseTexture || !baseTexture.valid) return false;
|
if(!texture || !baseTexture || !baseTexture.valid) return false;
|
||||||
|
|
||||||
const resolution = baseTexture.resolution;
|
|
||||||
const x = (point.x * sprite.scale.x);
|
const x = (point.x * sprite.scale.x);
|
||||||
const y = (point.y * sprite.scale.y);
|
const y = (point.y * sprite.scale.y);
|
||||||
|
|
||||||
let dx = (x + texture.frame.x);
|
if(!sprite.getLocalBounds().contains(x, y)) return false;
|
||||||
let dy = (y + texture.frame.y);
|
|
||||||
|
|
||||||
if(texture.trim)
|
|
||||||
{
|
|
||||||
dx -= texture.trim.x;
|
|
||||||
dy -= texture.trim.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
dx = Math.round(dx) * resolution;
|
|
||||||
dy = Math.round(dy) * resolution;
|
|
||||||
|
|
||||||
if(((dx < 0) || (dx > texture.width)) || ((dy < 0) || (dy > texture.height))) return false;
|
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if(!baseTexture.hitMap)
|
if(!baseTexture.hitMap)
|
||||||
@ -124,6 +111,18 @@ export class ExtendedSprite extends Sprite
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
const hitMap = (baseTexture.hitMap as Uint32Array);
|
const hitMap = (baseTexture.hitMap as Uint32Array);
|
||||||
|
|
||||||
|
let dx = (x + texture.frame.x);
|
||||||
|
let dy = (y + texture.frame.y);
|
||||||
|
|
||||||
|
if(texture.trim)
|
||||||
|
{
|
||||||
|
dx -= texture.trim.x;
|
||||||
|
dy -= texture.trim.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
dx = (Math.round(dx) * baseTexture.resolution);
|
||||||
|
dy = (Math.round(dy) * baseTexture.resolution);
|
||||||
|
|
||||||
const ind = (dx + dy * baseTexture.realWidth);
|
const ind = (dx + dy * baseTexture.realWidth);
|
||||||
const ind1 = ind % 32;
|
const ind1 = ind % 32;
|
||||||
const ind2 = ind / 32 | 0;
|
const ind2 = ind / 32 | 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user