Change Slider image during sliding in Cocos-2d-x - cocos2d-x

I wish to use a slider in Cocos-2d-x where when you slide it, a new sprite image should be shown which shows the value of the slider.
I mean as we increase the slider value the width of this image increases and vice versa.
Is there any in-build function for this.

Related

LibGDX how to make a buttons size independent of image

When adding images to a TextButton in LibGDX how would I match the button to the contents of the image. Currently when I set size the image scales down to fit the button which leaves a large gap between the edge of the button and the contents of the image (See distance from green debug border to the edge of the buttons image).
I would like to be able to set the size of the button to match the content of the image so that the empty space around the image is ignored. I could crop out the empty space from the image but would have an off centered image due to the drop shadow and so would like to avoid that.
Top image shows the displayed dutton in game including the debug button border in green. Bottom image shows the source image with empty space.
TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
buttonStyle.font = FontLoader.uiFont;
buttonStyle.up = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_BASE, Texture.class)));
buttonStyle.down = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_PRESSED, Texture.class)));
buttonStyle.over = new SpriteDrawable(new Sprite(assetManager.get(UISpriteLoader.SPRITE_UI_TAMING_BUTTON_HOVER, Texture.class)));
tameButton = new TextButton("Tame", buttonStyle);
tameButton.setPosition(1470, 1080-330-80);
tameButton.setSize(250, 80);
stage.addActor(tameButton);
Use a Ninepatch for your images. It will scale to fill the button out of the box.
I recommend you to use Skin Composer both for making the Ninepatches and for creating a Scene2d skin so you don't have to create your Styles in code.

image appear over other image on hover over

I am trying to create an image map where there is one main image, and when you hover over certain areas different images come up.
Something like this How to apply Hovering on html area tag? but instead of creating an outline it would show different images.
I do not want to usse jQuery and would prefer to rely on CSS and HTML.
Thanks in advance.
You could cover smaller blank images over the large main image and use the hover code separately for each image
The non hover image is a "blank" png and the hover is the desired result
Just use the code for each "blank" image with the main image in the background with z-index of "0"
As said in previous answer, you could do this by using the z-index property. But try setting the main image's z-index as 0, and all small images(that you want to show over main image) as lower than 0.
And finally, activate by swapping the z-index between values lower or higher than 0 on mouse hover.
Hope this helps :)

Adobe Edge Animate: Is there a way to use CSS media queries to resize an image?

I'm using Adobe Edge Animate and I'm really having trouble with all the different screen sizes and resolutions. I see that Adobe is coming out with new products which may address this issue. Basically all I'm tryng to do is have an image display (like a banner for example) that fills the width of the user's screen. I see the following questions, but answers are old and I know that there has been a lot of development in this area. Any ideas greatly apprciated.
Stackoverflow questions
From the splash screen. In the Properties tab change the switch next to the width to make it 100%. Select the Max W parameter and change this to too. All these tweaks will make the layout responsive. Next drag the image onto the stage and position in the top-left corner. In Properties click on Use Presets for Responsive Layout and choose the Center Background Image option, then Apply. This means the image will stay central whenever the stage morphs. Drag the bottom-right corner handle so the image fits over the entire background. Notice the image doesn’t scale or stretch but stays in the centre. In the Position and Size tab is an expand button; click this and add a Max W of (how many px your image is). Change the width to 100% and press Enter. It will jump right back to 75% but it has accepted the change. Click on the resize marker and drag to the left to see what happens when the stage is resized to a smaller layout. As you can see, the background is clipped but the image resizes to fit.
Here is a link to the tutorial I think this will better answer your question if you do this tutorial. http://www.webdesignermag.co.uk/tutorials/create-a-responsive-animation-with-adobe-edge-animate/

Flash Slider Component

I just started learning flash on my own and I decided to make a cool little image gallery (somewhat of a family album). When I test the movie the first image loads in the center. Below the image are little thumbnail sized buttons which can be clicked and the image will load in the center. Since I am going to be incorporating a lot of photos I would like to use a Slider (left to right) so I can scroll back and forth through the photos and find the one I want to click on to display.
Since I have no experience with Action-script I was hoping someone could get me started with that process and maybe explain how the Slider works.
Thanks!
You can create easily your own slider, and learn something in process :) .
In slider - moving of knob, must correspond to moving of gallery where size of gallery is translated to size of slider. That is basically it. So you will need some mathematical formulas and basic elements:
gallery.width/slider.width - to determine if gallery is wider than
slider (so you would want to proceed with sliding), you can also use this proportion to determine a size of the knob. So if gallery would be smaller than slider - then you may not render slider, or make knob the size of slider, so it would be not movable. Or make knob proportional size to size of overflow of gallery - just experiment with everything I'm writing here.
You would need to use also those elements:
gallery (Display Object),
mask/container for gallery (the visible part of gallery),
slider,
knob.
Rectangle object
Gallery would be just a Display Object that contains all images as children.
Mask/container would be display object that would provide boundaries of area where part of gallery would be visible
Slider - any Sprite
Knob - any Sprite
Rectangle - would be of course Rectangle object, with width of slider.width - knob.width, and height of 0, so it would allow to drag knob along a slider without going outside of it, by using function:
knob.startDrag(false, rect); // Use it at MouseEvent.MOUSE_DOWN of knob
knob.stopDrag() // Use it at MouseEvent.MOUSE_OUT of knob
You can create rectangle with this code:
new Rectangle(0, knob.x, slider.width - knob.width, 0);
And you would need to translate moving of knob to moving of gallery which would be something like this:
// When moving knob you can use this formula:
gallery.x = knob.y / (slider.width - knob.width) * (gallery.width - mask.width); // Use it at MouseEvent.MOUSE_MOVE of knob
I think that should be it, I wrote it from the top of my head based on some library I wrote some time ago, so please tell me if you will encounter any problems, but I think that are all basics you need.
Have a look at the ScrollPane
Add your thumbnails in a container and use that as the Scrollpane's source and scrolling will be taken care of

transparent JButtons in JFrame with a Background Image

I am making a Class that extends JFrame and have my custom background image on it..
I have two problems..
1) I want my background image to stay fixed sized that covers whole screen when maximized. How can I do that?
2) I want to add a transparent button and panels on the frame that does not disturb my background. Is there any easy way to do that?
help will be greatly appreciated... thank you
Load the image into a BufferedImage.
Add a ComponentListener to determine when the frame is resized. Use the frame size to calculate scaling and call BufferedImage.getScaledImage(xScale, yScale) to obtain a scaled image.
In your class you should be overriding paintBackground() to do the painting. Just call g.drawImage(scaledImage, getWidth(), getHeight(), this) to paint the image.
Any components you add to the frame need to call setOpaque(false) so the background gets painted underneath them.