Graphics

Reply

Level 3

Level 3
GibFather
Posts: 57
Registered: ‎23-12-2011
Message 1 of 7 (644 Views)
Accepted Solution

2D: Spritesheet example

I'm trying to use the SampleSprite example as a base to implement rendering from a spritesheet.  From what I've gathered so far, it's using the VertexBuffer to define the rectangle of the sprite.  Although I haven't solved it yet, does anyone have a basic solution for this problem yet?

 

If I figure it out, I'll try to post my solution.

 

Thanks!

www.kahunastudios.com
Please use plain text.

Level 3

Level 3
GibFather
Posts: 57
Registered: ‎23-12-2011
Message 2 of 7 (624 Views)

Re: 2D: Spritesheet example

[ Edited ]

Update: Well, I was able to get something to work using the SampleSprite example.  However, once I clean up the code a little I'll post the solution.  To give you a quick hint of how I solved it, the VertexBuffer was the key into solving the problem.  I had to modify the SetTexture method in the example to be able to calculate the UV coordinates for the spritesheet.

 

The simple solution takes into account a fixed width/height dimensions for each frame.  I also added properties to keep track of the number of frames by breaking up the spritesheet into rows and columns.  Knowing the width/height and how many rows and columns, I'm able to define a rectangle that will map exactly to the frame I want to render.

 

I'll post the code and example screenshots once I clean up the code.  Stay tuned.

www.kahunastudios.com
Please use plain text.

Level 3

Level 3
Rogerdodger91
Posts: 235
Registered: ‎02-12-2011
Message 3 of 7 (608 Views)

Re: 2D: Spritesheet example

[ Edited ]

i had modifed the image sample to display textures from a list. Basically all that I need to implement is the Image.Cropped method to select individual segments of a sprite sheet to add to the list. 

http://i1176.photobucket.com/albums/x326/rogerdodger91/pssuite.png
 

Please use plain text.

Level 3

Level 3
GibFather
Posts: 57
Registered: ‎23-12-2011
Message 4 of 7 (604 Views)

Re: 2D: Spritesheet example

Interesting!  I was also looking at the Image Crop example shortly after I implemented my solution.  I would love to see how you did it.  Thanks for sharing!  :smileyhappy:

www.kahunastudios.com
Please use plain text.

Level 3

Level 3
Rogerdodger91
Posts: 235
Registered: ‎02-12-2011
Message 5 of 7 (598 Views)

Re: 2D: Spritesheet example

http://pastebin.com/RCzrWbYg

Let me know if that shows up for you. I put it on private because of the NDA with Sony. Basically all I did was take out alot of the irrelevant code and then move some of the methods out of appMain, It still a work in progress, but it does automatically allocate vertices for each individual tiles.

However, im pretty sure this would be very irrelevant. Im wondering if just making a 2D plane and then pasting textures to it would be more efficient in this case.
Please use plain text.

Level 3

Level 3
GibFather
Posts: 57
Registered: ‎23-12-2011
Message 6 of 7 (596 Views)

Re: 2D: Spritesheet example

Cool!  I'll take a look at this in a few.  Yeah, I was also thinking of trying to create a blank Texture or canvas and create a render method to fill the current frame from the texture data from each sprite.  I'm still trying to get familiar with the Texture2D class.

 

Thanks for posting your solution and keep up the great work!

www.kahunastudios.com
Please use plain text.

Level 3

Level 3
Rogerdodger91
Posts: 235
Registered: ‎02-12-2011
Message 7 of 7 (592 Views)

Re: 2D: Spritesheet example

Lol, i dont deserve the credit. Thank the dev team. I didnt write the code, just removed the irrelevant stuff and organized the rest of it. :smileytongue:
Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News