playMaker

Author Topic: 2d toolkit change sprite image  (Read 7597 times)

msc4tech

  • Playmaker Newbie
  • *
  • Posts: 17
    • View Profile
    • http://www.msc4tech.com
2d toolkit change sprite image
« on: December 06, 2011, 03:16:16 AM »
this code change sprite by name


using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
   [ActionCategory("2D Toolkit")]
   [Tooltip("set sprite by name of tk2dSprite")]
   public class Set2DToolkitSpriteByName : FsmStateAction {
      [RequiredField]
      public FsmOwnerDefault gameObject;      
      [RequiredField]
      public FsmString spriteName;
      
      private GameObject go;
      private tk2dSprite sprite;
      
      public override void Reset() {
         gameObject = null;
         spriteName = null;
      }
      
      public override void OnEnter() {
         go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
         sprite = go.GetComponent<tk2dSprite>();
         sprite.spriteId=sprite.GetSpriteIdByName(spriteName.Value);
         Finish();
      }
   }
}

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: 2d toolkit change sprite image
« Reply #1 on: January 13, 2012, 01:09:25 AM »
Hi Everyone,

 I have started porting 2d toolkit and currently gathering custom actions. The package will be available very soon :)

 Meanwhile, if you have wishes or requests for 2d toolkit and playmaker, this is the right time to ask for it :)

 Thanks for ms4Tech for the head start on them actions.

https://hutonggames.fogbugz.com/default.asp?W717

 Bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
Re: 2d toolkit change sprite image
« Reply #2 on: October 31, 2012, 10:33:36 AM »
I know I'm bumping the dead here, but why is this not in the wiki package? It still works flawlessly
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: 2d toolkit change sprite image
« Reply #3 on: October 31, 2012, 10:36:13 PM »
Hi,

Thanks for reminding me. I haven't give yet a second rundown to it to include the various custom actions created since.

Can you bump again like mid november? I should have more time to allocate to this and update the wiki package with all the latest additions

bye,

 Jean

MasterMedia

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: 2d toolkit change sprite image
« Reply #4 on: January 26, 2013, 04:38:18 PM »
How did i switch a sprite image on a different sprite collection?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: 2d toolkit change sprite image
« Reply #5 on: February 08, 2013, 01:09:15 AM »
Hi,

 Uhm, I tried to look at this, but I can't find any convenient api to do that at runtime, the utilities seems to only exists in editors.

I can of cours elet you pick a library by index ( 0, 1, 2 etc), but that's not really convenient...

I have asked this to the 2dtoolkit guy, I'll see what is coming up from it.

http://unikronsoftware.com/2dtoolkit/forum/index.php/topic,1152.0.html

bye,

 Jean
« Last Edit: February 08, 2013, 01:16:28 AM by jeanfabre »