Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Wrong image is getting drawn

Author
Message
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 15:53
I'm running into an issue where the wrong image is being drawn; my entire code is included below, but here is the piece that is drawing incorrectly.



Instead of drawing the HUD; this always draws the background tile image (Default_B_G.png). I tried just changing the image to a couple of others to see what happens and it does the same thing.

damothegreat
User Banned
Posted: 21st Jan 2017 15:57
You can change layers on sprites - called Depth

So you can use

SetSpriteDepth ( HUDsprite, 0)
SetSpriteDepth ( playersprites, 1)


Call these just after creations

This will draw the HUD sprite first and then playersprites on top

You can try chainging the values according to how you wish it to display

Hope this helps
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 17:07
This is not a z-sorting issue with images drawing on top of each other. It is literally drawing the background tile sprite image INSTEAD of the image I specified in the LoadImage call.
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 17:13
To add some additional information I found; I'm pretty sure there is some kind of bug with AppGameKit here.

This only happens if the X,Y coordinates of the image is 0,0

So this code draws the wrong image



But this code will draw the correct image



Notice that in the set piece I offset the Y coordinate one pixel; that is the only difference.
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 17:16
Some additional info. I was able to work around this by taking my HUD image and changing the code so that it is the very first image to load. In my case that works ok as it should always display on top of everything at 0,0 coordinates, but there is definitely some kind of bug here.
damothegreat
User Banned
Posted: 21st Jan 2017 17:31
Yeah - I see it happening now


I think its the GetSpriteHit function - when you hover over the screen and once it HITs the bottom and top huds - they just disappear - cause the getspritehit function
is returning those sprites also been hit on the screen and your making them invisible


spr_hit = GetSpriteHit(GetPointerX(), GetPointerY())

if spr_hit <> 0
SetSpriteVisible(spr_hit, 0)
endif

This is picking up and identifying every single sprite loaded - including the HUDS

If you press F1 on GetSpriteHit function it will give you some ideas - and one of these ideas is setting the sprite depth of the HUDs to 0 and the tiles to depth 1
Or another technique is to use

GetSpriteCollision ( mouse, tileArray[idx] ) =1


Damo
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Jan 2017 17:46
there is also GetSpriteHitTest ( iSpriteIndex, x, y ) where you can test the sprite ids you need.
x,y should not test the sprite edges because float values.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 18:34
Just to reiterate; that is not the issue. The GetSpriteHitTest is just some conceptual code for something that I'm trying.

Here's a link to what it should look like

http://imgur.com/t071agf

Here is what it looks like before I changed the order of the LoadImage calls

http://imgur.com/QV6BLnd

Hopefully from the images it is clear this is not due to z-ordering issues or things being deleted. I'm pretty sure this is actually a bug in AGK.
damothegreat
User Banned
Posted: 21st Jan 2017 18:43
I get the same issue

Its not a bug - its cause your using getspritehit - this goes through every single sprite loaded - cause the huds are sprites. they are been made invisible too

Use this code instead



Damo
bigtunacan
9
Years of Service
User Offline
Joined: 24th Jul 2015
Location:
Posted: 21st Jan 2017 20:52
Ok, so it must be registering the mouse at 0,0 when it starts and that is deleting whatever image is on top at that position?

Apparently, I also had an off by 1 issue in my tilemap so there was an extra tile that would be drawn at 0,0 since it was never having it's position overridden.

Thanks
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Jan 2017 22:08
normal you start with a mouse button/touch screen state or pressed.
GetPointerPressed () get once a =1 after clicked
GetPointerState () =1 at hold

try one sync before main loop to get actual mouse pos.
AGK (Steam) V2017.01.09 : Windows 10 Pro 64 Bit : AMD (16.12.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)

Login to post a reply

Server time is: 2024-11-24 20:40:49
Your offset time is: 2024-11-24 20:40:49