This site requires JavaScript, please enable it in your browser!
Greenfoot back
gusbus123
gusbus123 wrote ...

2013/4/24

getting a particular part of a string to compare and use.

gusbus123 gusbus123

2013/4/24

#
example of what i am trying to do: i have a string that = "random" and i want to get just the 2nd letter in this string which in this particular scenario it is "a". How do i do this? Best in a for loop as i need to be able to go through every single letter and find/use each letter/number.
MatheMagician MatheMagician

2013/4/24

#
string.charAt(2);
Check here for more string methods.
gusbus123 gusbus123

2013/4/24

#
ty
gusbus123 gusbus123

2013/4/25

#
2nd problem, how can u draw 2 parts of a picture next to each other for 1 object? so if i had my own text style drawn in a picture file and i want to be able to set each letter to use the parts of this picture to display the word, how do i do this?
danpost danpost

2013/4/25

#
Create a GreenfootImage equal in width to the sum of the two images and draw the individual images on that new image at the appropriate locations. You can continue adding more letters in the same way using the last image created and the new letter image to add (create an image equal to the sum of the width of both of these and draw the images on the new image again).
gusbus123 gusbus123

2013/4/25

#
i get what u meen but whats the code for putting the image in the appropriate locations?
danpost danpost

2013/4/25

#
The first image is drawn at (0, 0), the new letter image is drawn at (first image width, 0).
gusbus123 gusbus123

2013/4/25

#
so its still using the drawImage(image, x, y) thing? and the x y is which location of the object the image is drawn?
gusbus123 gusbus123

2013/4/25

#
because im using a sprite sheet and want to draw different parts of the sprite sheet together to form a word/number
You need to login to post a reply.