Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Customizable hero clothes - how to? - Gideros Forum

Customizable hero clothes - how to?

Hey guys!
How can we make hero customizable? (considering that it has many animations: walk, jump, shoot, etc.)
image

First thing that came to mind is to create duplicate MovieClips, like
hero.mc=MovieClip.new --etc...
hero.mcRedShirt=MovieClip.new --etc..
hero.mcGreenShirt=MovieClip.new --etc..
Then after user gets red shirt, we assign:
hero.mc=hero.mcRedShirt
Or maybe switching texture pack is better?
heroTPack=TexturePack.new("heropack.txt","heropack.png",true)
heroTPack=TexturePack.new("heropackRED.txt","heropackRED.png",true)
heroTPack=TexturePack.new("heropackGREEN.txt","heropackGREEN.png",true)
hero.mcRedShirt=MovieClip.new --all frames we get from heroTPack
Then after user gets red shirt, we assign:
heroTPack=heroTPackRED --(I'm not sure if MovieClip will instantly switch texture, or it should be reloaded?)
Any better solutions?

P. S. And can we make different wardrobe items customizable?
Let's say hats, pants, t-shirts, there will be lots of combinations, it will be too complicated to manage so many movieclips or texture packs.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
customizableHero.png
450 x 140 - 47K

Comments

  • keszeghkeszegh Member
    with skeletal animation this would be easier yet nobody made such a thing for gideros as far as i know. see e.g. https://godotengine.org/article/godot-gets-2d-skeletal-deform

    switching texture pack seems to be a good option as of now.
  • SinisterSoftSinisterSoft Maintainer
    edited May 7
    Use variables for the names or preload and use indexes into a table.

    I do that for this:


    Likes: Apollo14

    +1 -1 (+1 / -0 ) Share on Facebook
  • antixantix Member
    edited May 7
    Gideros does support Spine (skeletal animation) and there is some code floating about for that purpose.

    If customization is really for the player then you could use a RenderTarget, draw the hero base to it, then add hats and clothes etc.. then use that texture for your Bitmap.

    If you can use Spine that would be easier though :)

    Likes: Apollo14

    Follow me on FaceBook Check out my DevBlog, my GitHub, and try my games...
    Falling Animals | Breaky Wall | Exetor | Mini Putt Golfing | Ninja Fruit Master
    +1 -1 (+1 / -0 ) Share on Facebook
  • olegoleg Member
    edited May 7
    antix

    Spine працює в гідерос, тільkи ящо анімація без мешів (сітоk)

    Apollo14

    яб на твоємe місці зробив оkрему анімацію MovieClip для руk, голови, ніг, тулувоща - а потім зібрав всі ці анімації в 1 спрайт і ним вже рухав, а kоли треба змінити теkстуру міняв тільkи анімацію тулувища

    Likes: Apollo14

    +1 -1 (+1 / -0 ) Share on Facebook
  • Apollo14Apollo14 Member
    edited May 8

    Use variables for the names or preload and use indexes into a table.

    @SinisterSoft Can you please share code snippet?
    (I totally didn't get the idea :p )
    oleg said:

    яб на твоємe місці зробив оkрему анімацію MovieClip для руk, голови, ніг, тулувоща - а потім зібрав всі ці анімації в 1 спрайт і ним вже рухав, а kоли треба змінити теkстуру міняв тільkи анімацію тулувища

    Thanks @oleg ! Definitely I should try different movieclips for different body parts of hero. I'm not sure how manageble it will be, but I think it's worth testing.
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
  • Apollo14Apollo14 Member
    Guys, I'm testing simple texturepack switching, but it doesn't work for me (I've attached gproj with sprites)
    How to properly switch texturepacks?

    I've managed to work only movieclip switching. And I have to remove movieclip from parent every time, and then add it again. Can we reload movieclip without removing/adding it from parent?
    (anyway if we could switch texturepacks, it would be much better, no need to create lots of movieclips)
    tpack = TexturePack.new("pics/walk.txt", "pics/walk.png", true)
    tpackRED = TexturePack.new("pics/walkRED.txt", "pics/walkRED.png", true)
     
    heroPics={}
    for i=1,5 do
    	heroPics[i] = Bitmap.new(tpack:getTextureRegion("walk"..i..".png"))
    end
    heroPicsRED={}
    for i=1,5 do
    	heroPicsRED[i] = Bitmap.new(tpackRED:getTextureRegion("walk"..i..".png"))
    end
     
    local mcBLUE = MovieClip.new{
    		{1, 10, heroPics[1]},	
    		{10, 20, heroPics[2]},	
    		{20, 30, heroPics[3]},	
    		{30, 40, heroPics[4]},	
    		{40, 50, heroPics[5]}
    	}
    mcBLUE:setGotoAction(50, 1)
     
    local mcRED = MovieClip.new{
    		{1, 10, heroPicsRED[1]},	
    		{10, 20, heroPicsRED[2]},	
    		{20, 30, heroPicsRED[3]},	
    		{30, 40, heroPicsRED[4]},	
    		{40, 50, heroPicsRED[5]}
    	}
    mcRED:setGotoAction(50, 1)
     
    mc=mcBLUE
    stage:addChild(mc)
     
    stage:addEventListener(Event.TOUCHES_END, function()
    	mc:removeFromParent()
    	if mc==mcBLUE then mc=mcRED else mc=mcBLUE end
    	stage:addChild(mc)
     
    	--switching movieclip works, but switching texture pack doesn't work:
    	--tpack=tpackRED
    end)
    zip
    zip
    testHeroCustomizing.zip
    529K
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
  • totebototebo Member
    I've started using Bitmap.setTextureRegion() recently. It's efficient and if you keep the graphics the same dimensions, could help you "skin" a character easily by using this command.

    Likes: Apollo14

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 ) Share on Facebook
Sign In or Register to comment.