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 / Drawing part of a sprite

Author
Message
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Apr 2012 21:03
Hi,
I need a technique to draw a part of an existing sprite. I started play with UVs in order to understand the mechanism of UVs but the following code does nothing! (I mean I see the sprite without any visual effect)


I was expecting to see a diagonally moving sprite in the same position
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 13th Apr 2012 22:11 Edited at: 13th Apr 2012 22:26
You are using integer variables for the u and v

These need to be floats - change to u# and v#

if you want it to do a full cycle, you should also reset back to a minus value rather than zero - but this depends on what your final goal is.

Try this instead to demo the effect

I've also reduced the amount it moves to make it more visible

edit: added code changes
george++
AGK Tool Maker
17
Years of Service
User Offline
Joined: 13th May 2007
Location: Thessaloniki, Hellas
Posted: 13th Apr 2012 22:39
Thanks a lot.
I thought that setting a value using the comma, the compiler declares the variable as a floating point...
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 13th Apr 2012 22:56
Having not done anything with the UV commands either, I thought I'd try the sample code from Marl.

Naturally, because I needed to use an image I actually have, I changed the image name.

I thought the results were kind of cool, and interesting.

It appears that any bits of the image that touch the edge of its space get dragged and there is a strange target-like cross appearing.

Source image:


Displayed sample:


After reading the documentation on the SetSpriteUVOffset function, I thought it might be a result of the image size (144x144) and so I tried an image that was power of 2 (128x128).

Source image:


Displayed sample:


I ran this on a Windows 7 64bit machine, latest AppGameKit build.

Cheers,
Ancient Lady
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 14th Apr 2012 00:00
you need to draw a 1 pixel transparent border around your sprites
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 14th Apr 2012 18:22
That sounds right.

I don't have any plans, yet, to use the UV stuff.

I was just curious about how it worked.

Although, the effect is kind of interesting. I can almost envision something cool being done with this.

Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-11-23 08:58:07
Your offset time is: 2024-11-23 08:58:07