Jump to content

Can I load a spritesheet with BABYLON


Herbert
 Share

Recommended Posts

hi guys,
Is there a way to load 2D-resources as spritesheet in BABYLON, and I can take the frame I want by alias(frame_1.png or frame_2.png)?

or if I need to do it myself,  where can I set the attributes like clipX, clipY ......to get the part of image I want

{"frames": {

"frame_1.png":
{
	"frame": {"x":1,"y":1417,"w":93,"h":102},
	"rotated": false,
	"trimmed": true,
	"spriteSourceSize": {"x":5,"y":0,"w":93,"h":102},
	"sourceSize": {"w":98,"h":102}
},
"frame_2.png":
{
	"frame": {"x":311,"y":1187,"w":84,"h":102},
	"rotated": false,
	"trimmed": true,
	"spriteSourceSize": {"x":13,"y":0,"w":84,"h":102},
	"sourceSize": {"w":98,"h":102}
}},
"meta": {
	"app": "http://www.codeandweb.com/texturepacker",
	"version": "1.0",
	"image": "sprite_sheet.png",
	"format": "RGBA8888",
	"size": {"w":1922,"h":1555},
	"scale": "1",
	"smartupdate":
}
}

 

Link to comment
Share on other sites

hi @Deltakosh

I only find sourceXXX properties in GUI.Image. So perhaps I should create my own imageButton class based on GUI.Image.

By the way, GUI seems only shows on the scene which is created LAST, not so sure if it is a bug?

I borrow the PG in this post and make some changes to reproduce the issue(http://www.html5gamedevs.com/topic/15501-changing-scenes-locations/)

here's the PG(http://www.babylonjs-playground.com/#1B3R9A#33)

so I create a GUI button while scene 0 is being rendered(button not showing)
then I switch to render scene 1 which is created later(the button is there)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...