WP7 progressBar with gradient foreground behavior - windows-phone-7

I was thinking how to explain this. Better with a image:
http://www.foxandxss.net/stuff/progressBar.png
I want a progressBar with that gradient.
The first one is when the value is 100. The progress bar is full and it show the whole gradient.
But when the progressbar's value is 50, I get the second result. a 50% filled bar with the whole gradient.
What I want to archieve is the third one, when the bar's value is 50, the gradient has to be 50% also.
How can I archieve that? Opacity mask? (First guess but maybe I'm wrong).
Well, I appreciate some help. Thanks!

A quick way could be to have the entire gradient bar, like in image 1, and simply move the black bar across towards the right. This will give the illusion that the gradient bar is growing when really, it's just 'uncovering' the gradient bar.
On a side note, you should be careful with gradients as WP7 devices display a lot of banding. You could add dither to reduce the banding. I think I heard that the Mango update fixes this, but I'm not 100% sure on that.

Related

Achieve pixel perfect on Canvas?

I want to make exact 1-pixel thick line without distortions. (means not appeared as 2-pixel lines or 1.5-pixel lines, etc) Because it seems like the Canvas just can't stand Pixel Perfect at times.
It is also depends on CanvasScaler setting, make sure that screen/canvas output is exactly at scale 1x.
Confirm that canvas final scale is all 1x
Also confirm that your displaying game window has 1x scale so that 1 pixel show up nicely too!
(View full unscaled image in another window if sprite in above image appear jagged)
For canvas scaler setting, if you use it in other mode such as "Scale with screen size", and its reference resolution did not match current game window, it will result in non 1x scaling.
If scale is non uniform, jagged or blurry line will start to appear on canvas.
Notice the middle sword sprite.
Canvas' pixel perfect tick box helped nothing so far.
Actually, sorry. Canvases try to respect screen pixels when scaling with PixelPerfect set to true.
The solution was pretty easy - just setting PixelPerfect to false. I got so used to set it to true (because of the UI style I was going for before) that I didn't even consider turning it off. I guess that's mainly due to its name - Pixel Perfect.
xD

Libgdx | Set black color to everything outside of circle

How can I set a black color to the whole screen, excluding a shaperenderer circle? The circle is basically my game world, anything that leaves it shouldn't be visible. Is there some way to create a reverse circle pixmap (eg..A circle, but inverted) to overlay everything except for the circle game area? Or maybe a way to clear the screen, excluding parts? Thanks!
You could try the approach you mentioned in the comments. Using a black image with a circular hole in it. Then have each assigned to a different camera much in the same way you would set up a HUD in libgdx.
You might want to take a look at shaders, this approach is really flexible and lets you even control how rapid the transition is. Just the basics of GLSL should be sufficient.
https://www.youtube.com/watch?v=caQZKeAYgD8 Here's a decent tutorial.

Is there a way to make the view called when UIImagePickerController.allowsEditing = true have a circle instead of square?

I'm trying to implement a way to allow a user to quickly edit which portion of their selected photo to be an icon. However the default state is simply a square but my icons are circles. I know I can simply make a circle from the square image they select but from a UX standpoint that's not ideal. I would prefer them to simply select an image with knowledge of it being a circle in mind.
As far as I know, there is no way to easily do this. I would suggest keeping it as a square and simply displaying the image in a round imageView.
There should be no significant difference between saving the image as a circle and displaying it as a circle.
Hope this helps.

Flash animation help

I am a complete novice when coming to using Flash but I am looking to create an animation similar to the line into text animation at:
http://www.louisebradley.co.uk/fl/
where instead of running from the top of the screen I want the line to effectively stretch across my homepage horizontally.
I have created an animated gif that does the job but it takes a long time to stretch across 974 pixels in width, and if the frames are reduced it takes away any smoothing effect. I did this in photoshop by simply creating 20 or so frames, each increasing the size of the line by 60 pixels until the full page is covered.
Would I be better off creating the effect in Flash? And if so, where on earth do I start!! Would tweening do this, and how I would I implement it?
Thanks in advance for any help!
I am assuming you are talking about the line to the left of the main navigation? If this is the case, this is being done using a mask that is tweened. You can simply draw out the shape you want "wiped" across the screen and than on the layer above it, draw a box over the shape to be animated. Right click the layer the box is on and select "mask". You can now tween the mask to move from right to left over the shape you drew and it will appear to wipe over. Just remember, whatever the mask is currently over, is what will show through from the layer that is masked. Think of the mask as a window. This can be completely done without actionscript and only using the timeline.

How does UIScrollView like scrolling work?

in my opinion the iPhone has a big advantage to other smartphones because of its intuitive, smooth and good feeling scrolling components in UIKit. I want to implement a simple game with UIKit which uses this kind of scrolling, but i can't use UIScrollView because it isn't customizable enough.
I tried to implement this scrolling myself and tried two different approaches:
I used a UIPanGestureRecognizer und moved the bounds of my custom control according to the translation the recognizer delivers me. In order to get this smooth scrolling after lifting my finger during the movement I start an animation. I use the velocity the recognizer gives me and a fixed time in order to calculate how far it should scroll after I lifted my finger. I tryed a linear movement and a ease-out movement, but both looks strange. (more later on that)
I use OnTouchMoved and OnTouchEnded to implement the scrolling. In OnTouchMove I move the bounds according to the movment of the finger. While the finger moves I calculate the difference in location and time of the current and last touch in order to calculate a velocity myself. When the finger lifts I start an animation in OnTouchEnded like in 1. but I use my self-calculated velocity instead.
Both approaches are not giving me the results I want. After lifting my finger, the scrolling is not smoothly continued. There seems to be a (sharp) bend in the celocity curve.
Has anyone an idea how apple does this smooth scrolling? My current guess is that my interpolation with two really close points is to inaccurate and doesn't take the current acceleration into account.
Thx for your thoughts!
Kie
Why don't you add a UIScrollView as handle on top of your view, without visible content. Then you can use the UIScrollViewDelegate methods to update your real view on certain actions. For example: if you capture the scrolling of the UIScrollView using scrollViewDidScroll: , you can update your visible view with the offset of the scrollview. You can use the scrollViewWillEndDragging: to start synchronizing the main view with the scrollview, and scrollViewDidEndDecelerating to stop synchronizing.
I use the same approach to scroll the background of my Animix app. It has an invisible scrollview at the bottom, to give the user the feeling he can drag the grass to the left and right to move the background.

Resources