Sprites, Button Images and Callback Actions

the images on each button/sprite don’t work

They’re all 404 in the console for that playground, so I’m not sure what you’re seeing that makes them semi-transparent. I updated your playground to use the ‘textures/player.png’ sprite provided by the playground server and it looks correct.

is there a way to make the entire SPRITE an image? Like this playground? https://www.babylonjs-playground.com/#XCPP9Y#3281

I’m not sure what you’re asking for here. Maybe you’re asking how to use the BABYLON.GUI.Button.CreateImageButton function with a sprite? This might help: How to import Textures and Images from a sprite sheet? - #7 by earthendev

Question 2) trying to pinpoint the BUTTON name or SPRITE name, so I can control the action in the onPointerDown callback. I’ve used the following format before to catch actions (see line #104 in playground above)

this usually works —> (pickinfo.pickedMesh.name == “button6”) or (pickinfo.pick> edMesh.name == “b6”)

but it’s not working in this example above. How can I access the sprite/button and catch the action in the onPointerDown callback? The material line seems to work fine in the example…

There is a different function for sprite picking. See:
Picking Sprites | Babylon.js Documentation (babylonjs.com).

I updated your playground to show it:
my menu | Babylon.js Playground (babylonjs.com).

Does that help?

1 Like