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 / repeat image on sprite

Author
Message
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 7th Jun 2015 10:17
how do I repeat an image in a sprite instead of the image being stretched? I want to be able to have the sprite at any width or height but to repeat the pattern when resized. tried a few things but didn't work.

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 7th Jun 2015 12:27
The command you need is:
SetSpriteUVScale

Where U is horizontal and V is vertical.
A value of 1 means leave it as it is. So 1 = 100%
If you want to repeat the image 10 times then you need to set U, V or both to 10% which is 0.1

AGK V2 user - Tier 1 (mostly)
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Jun 2015 11:51
tried that and a few things, from what you say do i simply divide by 100?


swi# and she# are values put in edit boxes within my editor.
the above code aint looking right visually anyhow so I am still puzzled

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Jun 2015 12:22 Edited at: 9th Jun 2015 14:26
You will need to set the image wrap as well.
SetImageWrapU()
SetImageWrapV()

The defaut is to clamp the last pixel but you will want to change it so that it wraps.

Here is a small function to demonstrate it.
The upper image is the default sprite.
The lower image is the sprite 'stretched 10 times.
When you click the mouse, the image is tiled 10 times to give the appearance of 10 sprites in a row but it is still just one.



[Edit] Added the sprite that I was using to demonstrate the code - not that it matters too much, you can use any sprite.

AGK V2 user - Tier 1 (mostly)

Attachments

Login to view attachments
shadey
14
Years of Service
User Offline
Joined: 25th Jan 2010
Location:
Posted: 9th Jun 2015 18:34
ah! thanks for that, I wasn't dividing 1.0 by the scale size obviously! Not used to dealing with float stuff

Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk

Login to post a reply

Server time is: 2024-11-25 22:33:59
Your offset time is: 2024-11-25 22:33:59