How to add android UI buttons with libgdx - libgdx

I want to create view that look like :
| |
| Animated Sprite |
|______________________|
| |
| Button | Button |
|__________|___________|
Animated sprite above buttons.
How can i achieve this with libGDX.

You cant use Android UI Buttons inside the libGDX Projekt. Try to create a regular libGDX Button, ImageButton or TextButton with a style like a regular Android button. Use a ninepatch as background and it shouldn't be that hard to create an Android Style button with a simple ninepatch.(All Buttons)
Also take a look at the Table layout for creaeting your whished UI. I guess you'll find everything there to create it.

Related

Adding g+1 button in Libgdx

I wish to add g+1 in my LibGdx based android gaming app. I am following this link to understand the g+1 related coding.
https://developers.google.com/+/mobile/android/recommend?hl=en
In Libgdx, we do not have a relative layout to have the button "com.google.android.gms.plus.PlusOneButton". Hence I plan to draw a g+1 button. But I wonder how to get the annotation bubble. getAnnotation() method is protected.
Please advice.

AS3 different image when a button is in use

I have an application for kind of like a homemade microsoft paint made completely in AS3, I am not that advanced in actionscript, but I will ask you my question and thank you in advance!
So I have buttons, each button is a drawing tool, and I want the icon for the drawing tool(button) to be something different than when it is up, down, roll, hit. A compleletley different image to appear ontop of the current button so the user knows what tool is in use while they are using it..
What would be the easiest way to do this with AS3, the timeline and use of movie clips?
Thanks!!
You want to define your button as an instance of SimpleButton, then set the images directly. Kind of like this:
var clearBtn:SimpleButton = new SimpleButton();
clearBtn.upState = mc2;
clearBtn.overState = mc2a;
clearBtn.downState = clearBtn.upState;
clearBtn.hitTestState = clearBtn.upState;
Which I took from a similar question / answer posed on the adobe forums.
If you have these buttons as MovieClips - just change their type to Button in the library. Each button has four keyframes 1- default state, 2 rollover, 3 hit and 4 hit area.
That's the easiest solution without coding.

how to actor render to Particular posistion without any inputprocess

i'm new to libgdx, I'm trying to make a sprite move to particular target. I can make the sprite move perfectly in x position. i`d move to target position without inputprocess like a enemy. I've tried a few different things but at this point its just guessing and checking.
o(actor) render to target from any position of screen.
/*
o((qx,qy)actor)
|
|
v
((lx,ly)actor)o--->target(tx,ty)<------o((rx,ry)actor)
*/
pls helpme ...
I suggest you take a look at Universal Tween Engine. It's perhabs some overkill to just linealy progress a value across time but it will handle all the things you need. Just read the GetStarted page on the GoogleCode project of it to learn the basics.
Also, you can run a demoApp that showcase it's potential.
Here it's in HTML5
Here it's in Desktop
And here it's in Android
All three are done in LibGDX by the way.

ActionScript 3 code folding/regions

Is there any way to create foldable regions of code in ActionScript 3 (read this as Adobe Flash CS3 built-in editor). I'm looking for something like in MS Visual studio so that I can do:
#region "Event handlers"
... big list with methods here
#end region
Any ideas?
In the Flash IDE, select the code to fold and right click. A menu will appear with the following options: Collapse Between Braces | Collapse Selection | Collapse Outside Selection | Expand Selection | Expand All.
With that said, you should seriously consider a 3rd party ActionScript development environment, such as FlashDevelop, a very well thought out alternative. It's a massive pain developing in the Flash IDE.
http://www.flashdevelop.org/community/viewtopic.php?t=202
Flash CS4 has a code folding feature. Just select/highlight a few lines of code and click the - icon on the left.
In the Flash CS5 IDE, select the code to fold and right click. A menu will appear with the following options: Collapse Between Braces | Collapse Selection | Collapse Outside Selection | Expand Selection | Expand All.
In Flash CS3, there was not really anything like that. CS4 introduced conditional compiling, not really what you are looking for; but it does not get any closer.
Like already suggested, I would suggest using FlashDevelop. It has some folding options, but event more importently it has intellisense and automatic code generations. And it is free.
Flash CS3 calls it "Code Collapse".
On the editor toolbar:
Flash CS3 toolbar in editing mode http://img19.imageshack.us/img19/4558/picture23s.png
The buttons with facing arrows will collapse code between braces or the current selection. The button with arrows going out will expand code.
You can also find the commands in Edit->Code Collapse, which shows the keyboard shortcuts. Or you can right-click on the code you wish to collapse to get a menu of various actions, among them, collapse options.
If you are using FlashDevelop it has a terrific solution. You can create regions to conclude your code like this:
[-] //{ start region
your code here...
//} end region
and expand like methods
[+] //{ region Public methods
sth. like #region would in CS5 be:
//Controlls
{
public var IWaffe:MovieClip;
public var IWaffeD:MovieClip;
public var ICursor:MovieClip;
public var IFeuer:MovieClip;
}
and then you can use the collapse brackets button.

From Rectangle into trapezoid

how can i transform rectangle into trapezoid with ActionScript3
my trapezoid is a floor of 3D room, and i want to texturize it (bitmap tile).
_____________
| | | |
| |_____| |
| / \ |
| / trapez.\ |
|/__________\|
It depends on how the "rectangle" is represented in your program. Few options:
If your rectangle is vector, and you have access to the anchor points:
---> o------o <---
| |
| |
o------o
Becomes:
o--o
/ \
/ \
o------o
Simply translate the two top points and condense them to each other.
If that 'rectangle' is actually a DisplayObject, you will need to 'stitch' two of the same DisplayObject to create a new one. This page has examples of what you want along with example code.
Another option would be to use Papervision3D - which is using the above rendering method as a base.
This one's a bit tricky, but it's an option. You can use displacement maps as described here. The code is AS2, but it should be fairly simple to "port".
EDIT
As par this answer, I suggest you use Papervision3D (see 3rd option) to do that, as you might want to move the camera around the "room". It will also take care of the other walls as well.
the idea is to divide it into triangles and then perform an affine transformation (using Matrix) on them ...
senocular provided sample code (for AS2) ...
there's also a handful of libs online, but I can't find any right now ...
If you're targetting FlashPlayer 10 you can do it by rotating the clip's rotation values, see This post form Mike Chambers for details.
Otherwise you're going to need a 3D engine like Papervision. There's no simple way to do non-affine transformations in Flash Player 9.
Good luck.