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 / drawSprite not doing what expected

Author
Message
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 2nd Jan 2015 13:12 Edited at: 12th Apr 2018 21:00
What i want is to paste several images that are the same one after the other but what im getting is one sprite at the last location



</div>
fubar
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 2nd Jan 2015 13:26
Every time you Sync(), you clear the backbuffer, so you're only getting the last drawn sprite.

Are you trying to set up a playing area? If so, you should do all of your DrawSprite()s with no sync, then Render(), then GetImage to save the result. This way, you don't have to redraw the area every cycle.

Quidquid latine dictum sit, altum sonatur
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jan 2015 13:30
GetSpriteHit does not return the number of sprites hit, it returns the Id of the top sprite at the point given.

http://www.appgamekit.com/documentation/Reference/Sprite/GetSpriteHit.htm

It's a little hard to tell exactly what you're trying to do here but it seems this is the misconception you are working under.

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Jan 2015 14:43
sync() // = Update() Render() Swap()

if u only need a tiled background
mode to use, 0=clamp, 1=repeat
SetImageWrapU
SetImageWrapV
SetSpriteUVOffset ( iSpriteIndex, u, v )
SetSpriteUVScale ( iSpriteIndex, scaleU, scaleV )

AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 2nd Jan 2015 15:14
Ive got it doing almost what i want now but ive been using setSpriteDepth to hide the sprite after but its not hiding the sprite until after the subroutine has been called twice ive tried sync() Update() render() and Swap()
do

// find out which sprite gets hit
if ( GetPointerPressed ( ) = 1 )
sprite = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) )
endif
If sprite >1 and sprite <= 8 then playGame(sprite)
// update the screen
sync():sprite=0

loop

function playGame(spriteNum as integer)
SetSpriteDepth (14,9998)
SetSpriteDepth ( 9, 1 )
SetSpriteDepth ( 10, 1 )
SetSpriteImage ( 14, 100 )
clearScreen()
drawSprite(14)
render()
for image=0 to spriteNum
if getImageExists(image+1) then deleteImage(image+1)
next image

for x = 0 to (spriteNum)
SetSpritePosition( 9, (x*32)-32,0 )
DrawSprite (9)
SetSpritePosition( 10, (x*32)-32,32 )
DrawSprite (10)

getImage (x+1,0,0,480,320)
SetSpriteImage ( 14, x+1 )
DrawSprite (14)
render()

next x
setSpriteDepth (9,10000)
setSpriteDepth (10,10000)

sync()
endfunction playGame

fubar

Login to post a reply

Server time is: 2024-11-25 14:35:59
Your offset time is: 2024-11-25 14:35:59