Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Changing texture — Gideros Forum

Changing texture

misterhupmisterhup Member
edited March 2016 in General questions
I have a sprite and I want to change it's texture, but I can't use a MovieClip because I have to work with it's anchor point,size position, etc...So is there a way to change a sprite's texture more directly?

Comments

  • piepie Member
    Hi, it all depends on how you are doing it right now, but there are some ways to the same result. A code snippet would help to help :)
    Ie: Add the bitmap you're using as a texture for the sprite as a property of your sprite, so that you can change it without killing the parent sprite
  • Thanks for helping! :)

    In my original code, I have to change the texture in a loop if a specific variable value follows some patters, but I doesn't matter. The point is, I need to change the image without changing the current properties. So can you give me a bit more specific details on how to do that? Sorry but I am kinda new to Gideros :(

    Code example snippet:
    local ninja = Bitmap.new(Texture.new("Personaje/i1a.png"))
     
    	ninja:setScale(0.3,0.3)
    	ninja:setPosition(350,800)
    	ninja:setAnchorPoint(0.55,0.84)
     
    	--change image here to another image, keeping the same properties
  • ar2rsawseenar2rsawseen Maintainer
    ninja.setTexture(Texture.new("newmage.png"))
    http://docs.giderosmobile.com/reference/gideros/Bitmap/setTexture#Bitmap:setTexture

    Likes: keszegh, misterhup, pie

    +1 -1 (+3 / -0 )Share on Facebook
Sign In or Register to comment.