This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-28 21:59:40

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Scores/Variables

How do you make a variable look fancy? Each time you set a variable, it has a orange color. But what if you wanted it to look diffrent, so that it does not look like a variable? How do you do that?


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#2 2013-01-28 22:40:40

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Scores/Variables

Well, I have done that with this project, but with it displaying months.

Here's how I would do it.

You have to make a sprite for each number place, say 4.

Then you make each one have 10 costumes 0-9.

Then you need a sprite to send messages to these display sprites.

Here is an example of what I'm talking about:

If <letter (4) of [score] = (0)>
broadcast [0_]
end
Excuse the poor blocking skills...

So, it's tedious but I think it will work.

You have each display sprite have 10
when I receive [0-9 v]
switch to costume# [0_]
Blocks, so that each one goes up a number and switches to the appropriate costume.

So the first when I receive block would be receiving 0_, the next one 1_ and so one.
Make sure that the next place up has more than one number in its message to make it different, so like for 0 in the tens place make the message "00_".

Also, either make sure that you will never have more than 4 numbers or put a "if length of score = 5” statement, so that if score has more than 4 digits, you can make a 5th display sprite and have it the same way as the other ones, but it will only be signaled if score has more than 5 digits.

That might not be the most efficient way, but it's the only way I know.

If you want, I can try to make a project that does that and post it here, it may take a little while though.



Hope that helps,

CAA14

Offline

 

#3 2013-01-28 23:27:03

OverPowered
Scratcher
Registered: 2012-07-27
Posts: 100+

Re: Scores/Variables

One of the best ways to display a variable is to stamp it onto the screen using a sprite with 10 costumes of the numbers 0-9, with 1 as 1, 2 as 2, etc., and 0 as 10. The sprite functions on a simple script.

when gf clicked
forever
clear
set [Counter v] to (1)
go to x: (230) y:(170) //Rightmost starting point of text
repeat (length of (Score))
switch to costume (item (Counter) of (Score))
stamp
change x by (-5) //Width of widest letter
end
end
This should stamp text on the top-right corner of your game showing the score.  smile


Newest project: Tunnel TEST ~http://blocks.scratchr.org/API.php?user=OverPowered&amp;action=onlineStatus~ On my mind: Unicameralism

Offline

 

#4 2013-01-28 23:57:14

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Scores/Variables

Thanks for helping!!!   big_smile


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#5 2013-01-29 10:53:55

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Scores/Variables

No problem, i'm assuming that you used the simpler one above? :p
I don't yet know how to use lists or stamps, so its  good thing you commented, OverPowered!

Regards,

CAA24

Offline

 

#6 2013-01-29 15:03:08

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Scores/Variables

Not yet, but I will try....  smile  I am not on scratch, but I will try your idea!


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#7 2013-01-29 21:23:50

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Scores/Variables

Not on scratch? what does that mean? You don't use it?

Regards,

CAA14

Offline

 

#8 2013-01-29 21:47:08

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Scores/Variables

It looks like it does not work.  sad
But thanks for your help!  smile


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#9 2013-01-30 11:47:32

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Scores/Variables

Okay, I'm sorry to hear that, did you get it to work the other way?
You also must make sure that all your broadcasts are correct for my way to work, but you are not obligated to use my way, try the other one.

Regards,

CAA14

Offline

 

#10 2013-01-30 20:10:02

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Scores/Variables

I did not mean your way. I have not tried your way yet, but I will try it!  wink  I meant OverPowered's way. The script had one that said stamp. It took me all day to take the stamped sprite off.


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#11 2013-01-30 23:19:57

CAA14
Scratcher
Registered: 2013-01-14
Posts: 1000+

Re: Scores/Variables

Wow, so, you still have another way, good.  smile

Well, OverPowered's way i thought would work better... Oh well.

If you have any questions or would like me to make the engine and post it for you to download, then just ask.

Regards,


CAA14

Offline

 

#12 2013-01-31 16:41:33

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Scores/Variables

Ok.  wink


Did you know that you can go to space and see Mars by clicking here?

Offline

 

Board footer