How to make a sprite display a variable - mit-scratch

I am making a Undertale-Based game on Scratch, and I am trying to make a health counter that shows how much health you have. I could always make the variable viewable but I want it to fit in with the game and not stick out like a sore thumb. I've seen other games like Candy Clicker do this but I don't know how they make the sprite display the variable. Does anybody know how?

To do a sprite counter similar to Candy Clicker, you would need to use clones. You need to create a sprite with costumes for 0-9 numbers. Then you would need to have that sprite clone itself for however many digits you want to display, let's say 3, and then set its costume to the letter number of the variable that the clone's digit corresponds to. I'm not great at explaining stuff like this, so that might have seemed a bit complicated, so the short version is you need to create sprites that display the digits from costumes. I have created a demo at https://scratch.mit.edu/projects/677633446/editor with comments in the code.

Just put the variable in a "Say Block" and put that in a "Forever Loop".

Related

How to create a slider without an outline?

I want to create a slider without an outline.
Like this one:
Note rounded edges.
I assume I need to create a sprite for that. Unfortunately, I can't find any good tutorials on sprites for sliders. I think the easiest way would be to edit the built-in one but I don't know how to get it for editing.
This is how the original slider from my Unity looks like:
Note the outline.
So, surprising solution that should be available to all of us.
Put the default slider in and go to the Source Image for both the Background and Handle. Instead of using what is there, change it to another Unity Standard sprite called TouchpadSprite. This should do the trick. Not sure if the fact that this is called 'touchpad'sprite will cause a problem when make a PC game, but I doubt it. FYI the TouchpadSprite is from the "Standard Assets (for Unity 2017.3)" that is available for free in the Unity Asset Store. Feel free to only import the sprite itself. The Asset Pack itself is pretty large, but there is a lot of good/useful stuff in there.
Also, you will have to increase the Pixels Per Unit Multiplier value. My picture shows what I had to increase it to. This will allow you to choose the rounding of your edges as well. Play with it and let me know if it works.
Hope this helps!

3D Text visible from all angles

I'm making a soccer stadium, and I want to write the stadium name on the entrance of the stadium. But, when I'm in the stadium, or somewhere else, I also see the text. From all angles.
I know the help pages of Unity about 3D text and I read a lot of questions and answers about this problem. But I just can't fix it.
I tried to add a shader to a material, and I added the material to the 3D text, but then I can't add a font texture. I have the Arial font in my assets folder, but when I press 'select font texture', this font isn't in the options I can choose.
Isn't there another option to write text on a wall, on a way you only can see it from the front?
So, on the second picture I should't see the text:
Please don't think I'm lazy and I didn't Google, because I have searched for hours. But I really don't get it, it's probably something really stupid but I don't know what I'm doing wrong. I'm a beginner with Unity, especially with shaders and importing/adding fonts.
You can try https://www.assetstore.unity3d.com/en/#!/content/84126, its free and it will give the text in a form of mesh, so it will be just like any other gameobject, you can interact with it, use physics on it, etc.
There are multiple possible solutions, but the main ones are these:
You set the Canvas for that text to world-space.
To implement this solution, you can follow the official tutorial on the subject.
You can use a text-to-mesh conversion plugin.
There are many to choose from, but one that was officially acquired by Unity and is used by most indie developers when they need such functionality is Text Mesh Pro.

Measuring distance with iPhone camera

How to implement a way to measure distances in real time (video camera?) on the iPhone, like this app that uses a card to compare the size of the card with the actual distance?
Are there any other ways to measure distances? Or how to go about doing this using the card method? What framework should I use?
Well you do have something for reference, hence the use of the card. Saying that after watching the a video for the app I can't seem it seems too user friendly.
So you either need a reference of an object that has some known size, or you need to deduct the size from the image. One idea I just had that might help you do it is what the iPhone's 4 flash (I'm sure it's very complicated by it might just work for some stuff).
Here's what I think.
When the user wants to measure something, he takes a picture of it, but you're actually taking two separate images, one with flash on, one with flash off. Then you can analyze the lighting differences in the image and the flash reflection to determine the scale of the image. This will only work for close and not too shining objects I guess.
But that's about the only other way I thought about deducting scale from an image without any fixed objects.
I like Ron Srebro's idea and have thought about something similar -- please share if you get it to work!
An alternative approach would be to use the auto-focus feature of the camera. Point-and-shoot camera's often have a laser range finder that they use to auto-focus. iPhone doesn't have this and the f-stop is fixed. However, users can change the focus by tapping the camera screen. The phone can also switch between regular and macro focus.
If the API exposes the current focus settings, maybe there's a way to use this to determine range?
Another solution may be to use two laser pointers.
Basically you would shine two laser pointers at, say, a wall in parallel. Then, the further back you go, the beams will look closer and closer together in the video, but they will still remain the same distance apart. Then you can easily come up with some formula to measure the distance based on how far apart the dots are in the photo.
See this thread for more details: Possible to measure distance with an iPhone and laser pointer?.

iPhone Accessibility using "Red on Black" for images

Is there a way to convert an image on the fly to "Red on Black" for accessibility? I have pictures that I want to stream to the iphone. Viewing them at night, Red on Black is better for viewing.
Answer:
You're much better off making your own night friendly images, and swapping those out along with text color, etc.
I'm not sure how you have your current images implemented, but before they load you could check for BOOL isNightTime, and if it returns TRUE, then load the nightTime images instead. I would suggest taking your current image set, and duplicating it with the prefix nt_.
Bonus:
You can take this a step further. Grab the GPS location, then use the location to get weather information from Wunderground. Part of their report includes the times of Sunrise and Sunset. You could then use those values and check them against the current time (be careful that all the time zones are playing nice), and from the result of that, enable the NightTime image set.
If you do implement this, make sure that the user can still enable or disable it to his/her preference.
I had originally said NOAA, but I can't find where that information is on their website. I know it's there somewhere. Why are .gov sites so ugly? Anyways, I changed it to mention Wunderground instead, just scroll down to the Astronomy section. They have a pretty well done iPhone website as well, worth checking out.
Bonus 2:
I'm unsure what your maps/images look like, but instead of having to edit them all to red on black, you could instead edit them to white on black, and put a layer on top of that which would allow the user to pick any color/intensity. Instead of using a layer, you could likely also programmatically implement it, but I think a colorizing layer would be much faster/easier.
An alternate method of doing this is to instead make your map transparent/black, and put a layer underneath that which could change colors to the user's liking. You could implement this on a finer scale (place rects of color behind objects/text/whatever else) to allow for full color customization.
Both use transparency to some extent, but I believe that the alternate method requires less overall work.
Bonus 3:
If you're already going through the effort to grab the GPS coordinates, it wouldn't be too much additional work to have it also check with another server, which would point out other users using the application locally on the map. Make sure this is disabled by default, as lots of users are uncomfortable with broadcasting their location to the world.
Science:
It's also worth mentioning that green is a horrible color to use if you're looking for night friendliness. Red is the color you want to be using. Red light doesn't cause the eye to release the enzymes which cause you to lose your nightvision (what you get once your eyes adjust). This is the reason the inside of military vehicles usually have red interior lights, and also why every movie you've ever seen with tactical anything uses lots of red lighting.
Red light is also used to preserve night vision in low-light or night-time situations, as the rod cells in the human eye aren't sensitive to red.
-Wikipedia
I learned this when I went up to Kitt Peak National Observatory this Thanksgiving on a family trip to Arizona. They hand out little keychains with red lights on them, so you can see where you're going in the dark. It was probably one of the coolest things I've ever participated in. I learned so much. If you're in the Tuscon area, or have another observatory local to you, I strongly suggest checking them out.
The keychain they gave me broke and it fell off somewhere, it's nowhere to be found :( It was my only souvenir. If anybody from KPNO happens to see this and wants to mail me another one, my email address is in my profile.
Also here's a link that goes into far much more detail than needed, but I know you're all going to google it anyways.
I did find another solution:
http://sourceforge.net/projects/photoshopframew/
Source code is available and i can run the tiles through photoshop as part of a chain of events for night viewing.

Possible to change the alpha value of certain pixels on iPhone?

Is it possible to change just a portion of a Sprite's alpha in response to user interaction? A good example of what I mean is iFog or iSteam, where the user can wipe "steam" off the iPhone's screen. Swapping images out wouldn't be feasible due to the sheer number of possibilities where the user could touch and move...
For example, say you have a simple app that has a brick wall in the background that has graffiti on it, so there'd be two sprites, one of the brick wall, then one of the graffiti that has a higher z value than the brick wall. Then, based upon where the user touches (assuming their touch controls a sandblaster), some of the graffiti should be removed, but not all of it, which could be accomplished by changing the alpha value on a portion of the graffiti sprite. Is there any way to do this in cocos2d-iphone? Or, do I need to drop down into openGL, and if so, where would be a good place to start my search on how to accomplish this?
Ideally, I'd like to accomplish this on a cocos2d-iphone Sprite, but if it's not possible, where's the best place to start looking?
Thanks in advance,
Ben
The answer is here: http://www.cocos2d-iphone.org/forum/topic/7921#post-46394
But short answer: You have to override the draw method and resort to openGL methods.
I know this question is old, but it needs an answer anyway.