Author Topic: Bug using sprite.name to switch sprites  (Read 3865 times)

Donkey111

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 16
    • View Profile
Bug using sprite.name to switch sprites
« on: March 31, 2014, 11:43:38 PM »
Hi I have three generic sprites I use to display enemies before entering a level. I switch out the enemies using a script similar to this:

MySprite.spriteName = "TextureNameOfEnemy"

My problem is that the enemy is also a button (to get info on his stats). When you scroll over the enemy, the UIScale script makes him bigger. During this process he switches from his new sprite name back to the placeholder sprite!

I have a similar issue with a level background that switches from the "complete" back to the "unlocked." Same issue -- I set the sprite using .spritename but when I scroll over it with the mouse at runtime it scales and switches back to the "original" unlocked sprite.

Any suggestions?

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: Bug using sprite.name to switch sprites
« Reply #1 on: April 01, 2014, 01:40:29 AM »
Seems, that you have UIButton script on this sprite and have to set not only sprite.spriteName, but also uiButton.normal sprite, uiButton.hover sprite and so on.
I'm a busy man... I have places to go,monsters to kill...

Donkey111

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Bug using sprite.name to switch sprites
« Reply #2 on: April 01, 2014, 11:07:25 PM »
You are right AGB! Thanks!!!