So I'm working on piano app in Corona SDK (I'd like to say that I'm still a newbie to it). Basically the app layout is 'static' as I call it (there's no any scrollview etc.). Keyboard is situated on top of the screen and it covers like 1/5 of whole background, so every key is tiny, unplayable. And I don't know how to make zoom function containing buttons feature. If out there would be 2 buttons; one with '+' and one with '-', situated in bottom's 2 corners. I want them to don't change their size and position while zooming. Then when it's zoomed, no matter how deep, app work would be easily scrollable. I'd love the both, zooming and scrolling to be smooth, so you were be able to individually select your playing setup in your own preference. Can you help me and give some code suggestions, please? (as I said before I'm new..)
Thank you
First of all I suggest you to look into group programming guide. As I understand you need to place Keyboard in separate group and use xScale/yScale properties to zoom it.
--setup keyboard
keyboardGroup = display.newGroup()
sceneGroup:insert(keyboardGroup) -- sceneGroup may have different name in your code
--insert keys example
keyboardGroup:insert(yourKeyObject)
Zoom function:
function setZoom(xValue, yValue)
keyboardGroup.xScale = xValue
keyboardGroup.yScale = yValue
end
Zoom buttons should be placed in another display group, so they will not be affected by scaling
Related
So. Iv'e got a straight forward relative layout which I add multiple ImageViews to.
I don't want the images to obscure each other so as they are added they are translated so they don't.
As more ImageViews are added they need to be translated further and further away from the centre of the layout so as not to overlap other images and so they fall off the edge of the user's screen - no problem so far ...
I need to give the user the ability to pan to see the images that are off screen and also zoom in and out (with gestures not buttons) to see all images or focus in on one.
I think the solution to this problem is to modify the layout to allow pinch and pan but all I can find is how to create views that support pinch and pan.
I need each image to be in a separate ImageView.
Forgive me if this is the wrong way to come at this problem but any help would be much appreciated.
This might help explain:
want to scroll about and zoom around this layout (click to see)
I am using LibGdx to develop a game. For Now I am not using scene2D. I am struck up in increasing the levels of the game as I do not have the scrolling screen.
I like to design a a scrolling screen as it is in many games which are level based (for ref, lets say Candy crush). Could you please point me a example on how to have such a scrolling screen to show a bigger area where I can show many levels.
Thanks is Advance !
Using the Scene2D function is not necessary for this and is more for GUI implementation and different screens. The Scroll pane really shines when creating reading content that does not fit your phone. I do advice to start learning Scene2D to create MenuScreens and UI though.
What Candy Crush "simply" does is having multiple backgrounds that are placed next to each other and tile seamlessly. They use buttons in the correct place for levels. By dragging a finger across the screen the camera will move in that direction. For the movement from one level to the next there is probably something like a spline in play.
It is important only to draw the background tiles and buttons that are actually visible on the screen if you have many. Since these have fixed positions and you know your camera area and position you can calculate what to draw and what not. Just drawing everything each frame is likely to slow down your fps.
You can do a search on:
Tilemaps, for you backgrounds but you probably want them in just one direction so a simple 1D array would suffice.
Dragging, to move your camera. Here I gave a basic explanations on how I do it.
Splines, are a bit tougher and you do not really need them. They could be used to animate or move something along a curve.
Thats all, expecting you know how to create something like a button (click a sprite).
I have been trying to make a layout for an Android app that functions like a car Speedometer.
Something like this:
I basically want there to be 5 clickable Views across the radius of the dial, and have the dial point to the currently selected item. If possible it would be good to be able to click and drag the dial. I would also want this layout to work nicely with different screen sizes and resolutions, including tablets.
How could something like this be accomplished?
I don't know exactly how much this will help, but it goes over a similar design and shows how to place things at angles around a curve.
For each selectable view, I would also advise that you keep use keep track of the coordinates of each item, so you can use trig to calculate the proper angle for the dial to display (getting the dial to display at an angle is covered in that link).
So, you can set up OnClickListeners for each of your selectable items about the gauge, and in each instance, calculate the proper angle for the dial to spin to, and position it there using the information found in that link.
I'm not sure how much this helped, if at all, but it should at least give you an idea on creating custom Views and whatnot.
Good luck!
I'm developing an Android application to read "electric meters". The user enters the counter - the application calculates the consumption and sends it to a server.
The representation of the counter should look like a old electricity meters
old electricity meter
I've already integrated the counter-numbers as images. I will have an animation that if the user enters a number (keyboard) then the relevant section begins to rotate to the correct number position.
For example: The user enters the number 5 for the first digit, then rotate the digit from 0-5. The animated numbers flip to the correct position. How can I do this? Any idea?
thank u!!!
There is a custom view which I've created for a custom application. Initially, i also tried searching for this type of view but couldn't found any. So created one of my own.
You can see the code here: https://github.com/Vinayrraj/Android-FlipDigitView
Also this video might help you: http://youtu.be/d6-M2nN2Gzg
You can take a look to Ticker, an Android text view with scrolling text change animation:
Ticker is a simple Android UI component for displaying scrolling text.
Think about how an odometer scrolls when going from one number to the
next, that is similar to what Ticker does. The Ticker handles smooth
animations between strings and also string resizing (e.g. animate from
"9999" to "10000").
I'd have one spinning animation - but make it fast and blurred so you can't see what number it's on - play that for 1 second, then replace with the correct position - it's a trick, but will save you doing lots of different animations.
If I got your need, I would use two different approach:
1) one big animation with numbers from 0 to 9; when you have an inoput number, you should launch the animation and stop at the right frame (just a math calculation matter);
2) one animation for each number; you could think about a number flipping as if its rotating on itself vertically; then, when the user put his number X, you have to flip between X different animations until the good one and stop.
I am working on a project that involves painting on images.
To delete the unwanted lines or curves i have to draw a border and X button to delete it.
I have a relative layout where i have the freehand drawing canvas. on edit mode i should make them as u see in the pic, where i have to create button on a varying x,y positions.
i am confused how to achieve this.
Thanks in advance.
Jana.
I suggest doing this manually rather than using the Button widget. Override the onTouchEvent on the view holding your painting and use MotionEvent.getX and MotionEvent.getY in combination with MotionEvent.getAction to determine behaviour when the user touches the 'button'. Skipping widget creation will improve performance and open up doors to other types of functionality.
You could use the deprecated AbsoluteLayout container for this or keep the RelativeLayout and use layoutMargins to set the location of the buttons. The former is the route you should take despite the container being deprecated as the later breaks the layout paradigm by misusing margins...
You should keep in mind that there are a variety of devices with different screen sizes and setting explicit, pixel based locations is going to be awkward.