Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
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.
customizableHero.png
450 x 140 - 47K
> Newcomers roadmap: from where to start learning Gideros
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)

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 2018
    Use variables for the names or preload and use indexes into a table.

    I do that for this:


    Likes: Apollo14

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    edited May 2018
    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, Favfly

    +1 -1 (+2 / -0 )Share on Facebook
  • olegoleg Member
    edited May 2018
    antix

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

    Apollo14

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

    Likes: Apollo14

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
  • Apollo14Apollo14 Member
    edited May 2018

    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.
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • 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
    > Newcomers roadmap: from where to start learning Gideros
    "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
    “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
  • 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.