mm Posted January 15, 2016 Share Posted January 15, 2016 Hi, I'm new with phaser and would like to know if there is any way to add html class or id tag to images and sprites so some properties can be apply. Regards. Link to comment Share on other sites More sharing options...
Cudabear Posted January 15, 2016 Share Posted January 15, 2016 These images are drawn on a canvas, so they're not HTML elements in the traditional sense, and you can't use CSS to style them. What would you like to do with CSS, though? Most of the things you can do with css and html tags you can do with Phaser sprites already. Link to comment Share on other sites More sharing options...
mm Posted January 15, 2016 Author Share Posted January 15, 2016 I don't want to apply CSS, I have a js code for retina images but I need to look for them with a given class Link to comment Share on other sites More sharing options...
Cudabear Posted January 15, 2016 Share Posted January 15, 2016 Hmm, I'm not very familiar with retina images, but I suspect you can't find them in this manner. The images themselves do exist in game.cache, though, as bitmap data. Maybe you can use those? Link to comment Share on other sites More sharing options...
mm Posted January 15, 2016 Author Share Posted January 15, 2016 I'll keep digging on it, thanks for the help thou. Link to comment Share on other sites More sharing options...
Jackolantern Posted January 16, 2016 Share Posted January 16, 2016 Can you explain what you mean by "retina images"? Do you just need a reference to the images themselves, or do you need a reference to what is currently being displayed? If you just need the images, you can use vanilla JS to load the images separately, outside of Phaser and have them that way. If you need what is being displayed, that is more complex, because the canvas is essentially one entire moving bitmap itself. As Cudabear said, you can't target individual images on it separately once they are drawn. But there is always some way, even if you have to just grab the bits themselves, which is supported by canvas. So it just depends on what you need. Link to comment Share on other sites More sharing options...
Recommended Posts