Hi again 🙂
I continue learning about Spine, but I am finding difficulties when applying the functionality in java.
the firts question is about the color.
I see when you select on the editor a attachment, you can change the color, I find this very usefull for implement hair color customs!
but no idea how make this work on code.
since some post are very old, and they talk about a setColor that actually i cant find. so I tried
if(Gdx.input.justTouched()){
Slot slot = skeleton.findSlot("main_hair");
slot.getData().getColor().add(new Color(1,0,0,1)); //just try to color to a simple red hair
skeleton.setSlotsToSetupPose();
skeleton.setBonesToSetupPose();
}
but dont work, and no idea what to do 🙁
the seccond question is about change a body part:
for this case I want to use goblins as an example.
at runtime if i implement for change the full skin:
public void handdleInput(){
if(Gdx.input.justTouched()){
if(isMaleGob ){
isMaleGob =false;
skeleton.setSkin("goblingirl");
}else{
isMaleGob = true;
skeleton.setSkin("goblin");
}
this work perfect, but is here a simple way to change a single body part? for example I want switch de goblinGirl Head to the Male one.
public void handdleInput(){
if(Gdx.input.justTouched()){
Skin skin = skeleton.getData().findSkin("goblin"); //pick info from the skin i want
Slot slot = skeleton.findSlot("head");
int slotIndex = slot.getData().getIndex();
skeleton.setAttachment("head", skin.getAttachment(slotIndex,"head").getName());
skeleton.setSlotsToSetupPose();
skeleton.setBonesToSetupPose();
but get: java.lang.IllegalArgumentException: Attachment not found: goblin/head, for slot: head
Well I dont know if i go in the rigth way.... but atleas this work
public void handdleInput(){
if(Gdx.input.justTouched()){
Slot slot = skeleton.findSlot("head");
RegionAttachment attachment = (RegionAttachment) slot.getAttachment();
attachment.setRegion(atlas.findRegion("goblin/head")); //pick male head
attachment.getColor().set(new Color(1,0,0,1)); //change color head
attachment.updateOffset();
skeleton.findSlot("head").setAttachment(attachment);
}
}