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

#1 2010-08-29 15:00:14

indianaj
Scratcher
Registered: 2008-03-01
Posts: 13

How do you make text and number characters type? PLEASE HELP

I would like to display a score, but I don't want it in that corny orange box.  How do you script a sprite to stamp the numerals out?

Offline

 

#2 2010-08-29 15:21:54

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: How do you make text and number characters type? PLEASE HELP

Something like
go to (score display start
clear
Switch to costume (letter (1) of (score)
stamp
change x by (20)
If (length of (score) > 1
  Switch to costume (letter (2) of (score)
  stamp
  change x by (20)
  If (length of (score) > 2
      Switch to costume (letter (3) of (score)
      stamp
      change x by (20)

and so on and so forth.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#3 2010-08-29 15:25:39

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: How do you make text and number characters type? PLEASE HELP

AtomicBawm3 wrote:

Something like
go to (score display start
clear
Switch to costume (letter (1) of (score)
stamp
change x by (20)
If (length of (score) > 1
  Switch to costume (letter (2) of (score)
  stamp
  change x by (20)
  If (length of (score) > 2
      Switch to costume (letter (3) of (score)
      stamp
      change x by (20)

and so on and so forth.

Yep, also for that to work you will need to have the numbers set out in the correct order in costumes, you will also need to add a plus 1 block in the switch to costume bit so you can do zero.

Offline

 

#4 2010-08-29 15:41:19

hmnwilson
Scratcher
Registered: 2007-07-04
Posts: 1000+

Re: How do you make text and number characters type? PLEASE HELP

If it's just numbers, the best way is to have different sprites with costumes displaying the numbers 0-9. If the score isn't meant to go past 100, you could just use 2 of those sprites.

From there, you could put this in the sprite meant to display the entire score if it's 1 digit, or the second number if it has 2:
http://www.freeimagehosting.net/uploads/616842261b.gif

Then, for the sprite meant to display the first digit if it's over 10:
http://www.freeimagehosting.net/uploads/ac5acf2872.gif

Something like that would work. You can also do this with more than two sprites.

The other way would simply be to stamp every digit in order quickly, clear and repeat, but the problem with that is that part of the background needs to be visible at all times, and any sprites going over it will block it out.

Last edited by hmnwilson (2010-08-29 15:44:34)


I'm taking a break from Scratch until 2.0 comes out. Any messages sent between then and now probably won't be read - sorry.
(Oct. 20, 2011)

Offline

 

#5 2010-08-29 23:04:14

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: How do you make text and number characters type? PLEASE HELP

So make the score go over part of the background that doesn't change, copy that small part as a new sprite image, and stamp it first before stamping any score numbers.

edit: I'm working on a full-blown tutorial on this along with a simple demo project/game. It should be done sometime tomorrow. Oh wait, it is tomorrow lol. Starting to feel an all night code session coming on, been a while since the last one  smile

Last edited by Locomule (2010-08-30 01:14:50)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#6 2010-08-30 01:45:25

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: How do you make text and number characters type? PLEASE HELP

I think Scratch Resources has stuff on this if you're feeling lazy though...  tongue


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#7 2010-08-30 04:31:52

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: How do you make text and number characters type? PLEASE HELP

I wasn't feeling lazy  big_smile

Here is my tutorial which has a link to the demo project as well...
Score Stamping tutorial with demo game project


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#8 2010-08-31 01:57:11

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: How do you make text and number characters type? PLEASE HELP

I was talking to the topic owner - sorry about the confusion... ^^


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#9 2010-08-31 11:00:49

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How do you make text and number characters type? PLEASE HELP

AtomicBawm3 wrote:

Something like
go to (score display start
clear
Switch to costume (letter (1) of (score)
stamp
change x by (20)
If (length of (score) > 1
  Switch to costume (letter (2) of (score)
  stamp
  change x by (20)
  If (length of (score) > 2
      Switch to costume (letter (3) of (score)
      stamp
      change x by (20)

and so on and so forth.

Oh, dear. It's really troublesome to have to make a costume for everything. But I completely forgot about the (letter (x) of (x) ) block, and instead have been doing some really complicated math for as long as I can remember, to achieve the same effect. Thanks so much for pointing that out!

Offline

 

#10 2010-09-01 07:37:34

wei2912
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: How do you make text and number characters type? PLEASE HELP

The stamping method is good.


Waiting for Scratch 2.0...

Offline

 

#11 2010-09-02 19:19:52

indianaj
Scratcher
Registered: 2008-03-01
Posts: 13

Re: How do you make text and number characters type? PLEASE HELP

Thanks a lot

Offline

 

Board footer