Page 1 of 1

How to change icon when different arrow key activated?

Posted: Sun Feb 09, 2014 1:35 am
by layrian
Hi!

I'm trying to make a maze with a character with different sides when going different directions.
I tried something like this, but it does not work.

I imported the 4-direction pictures into a new card with individual names.
I tried
on arrowkey the key
if the key is "right" then
replace img "player" with img"player-right"
end arrowkey

what is the right way to do it?

Thanks !!!

Re: How to change icon when different arrow key activated?

Posted: Sun Feb 09, 2014 3:58 am
by Simon
Hi layrian,
Welcome to the forum :)

If you look-up "replace" in the dictionary you'll see that it's only for text.
Look-up "filename".

And umm... no need for the styled font in your postings unless you need it.

Simon

Re: How to change icon when different arrow key activated?

Posted: Sun Feb 09, 2014 4:20 am
by Dixie
layrian…

make the images that you have imported into your stack invisible through their property inspectors. In the development ‘menu’… select ‘Image Library’. You will see your imported images there. Move the cursor over them and note their ID numbers…

Place a transparent button on your card and in the script of the card use something like this…

Code: Select all

on arrowkey theKey
   switch theKey
      case "left"
         set the icon of button 1 to 1007
         break
      case "right"
         set the icon of button 1 to 1008
         break
      case "up"
         -- You could also do something here
         break
      case "down"
         -- You could also do something here
         break
   end switch
end arrowkey
I'va attached a stack, so that you can see it working

Dixie

Re: How to change icon when different arrow key activated?

Posted: Sun Feb 09, 2014 12:20 pm
by Klaus
HI layrian,

1. welcome to the forum! :D

2. I removed the unneccessary font size setting!
You will not get more attention when using bigger fonts, au contraire, mon ami 8)


Best

Klaus