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 / [Tier 1] can a 3D plane use a sprite instead of an image?

Author
Message
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 31st Jan 2018 10:58
I know how to load a normal image file into a 3D object:

MyPicture = CreateObjectPlane(1.0, 1.0)
shoeImg = loadImage("photo-of-a-shoe.jpg")
SetObjectImage( MyPicture, shoeImg , 0)

But I can't really figure out how to load a sprite sheet instead. Is it even possible?
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 31st Jan 2018 12:01 Edited at: 31st Jan 2018 12:01
Let's look to the Sprite commands

https://www.appgamekit.com/documentation/Reference/Sprite/CreateSprite.htm

A Sprite references an Image. ( integer CreateSprite( iImageIndex ) )

So a Sprite and a texture are nearly the same. What is a Sprite animation? It's a Part of an Image shown in a specific time.

So what would be ... if the texture is not shown the full image, but only a part of that image?

You could use that command, for having a bunch of imagedIDs, you could save the IDs in an array and change the texture of the plane every few frames or so
https://www.appgamekit.com/documentation/Reference/Image/LoadSubImage.htm
basicFanatic
6
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 31st Jan 2018 13:35
Thanks, that's a perfect solution! I stumbled a bit before I understood the workings of loadSubImage(), with text files used to define the position of the animation frames, but now it works. Also, the transparency was broken. But then I downscaled the image to a width of 2048 and now the transparency is back!

Login to post a reply

Server time is: 2024-04-25 11:30:42
Your offset time is: 2024-04-25 11:30:42