I need help to place a video at an arbitrary point on a playfield.
I am porting a game which takes place on a playfield - background with animated sprites superimposed. It's working fine.
The activity does a
// Set full screen view
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
Off that, I run a View on which all the action takes place. The playfield adjusts in size and offset, depending on screen size and orientation. All that's working fine, and I scale the sprites and their positions accordingly.
But sometimes, I need to place a borderless video on top of an existing background at various specific points in the playfield, and everything I read in stackoverflow is about the video itself and not how to position it. Can anyone help? Where should I start looking?
Ah... It appears that I wanted AbsoluteLayout, which became deprecated in 2009. There is, however, more than one way to skin a cat. I just have to work a bit harder.
Related
I have developed one desktop application using swing under which i have used JavaFx components, i have a few camera which i drag to the 2*2 layout view, it's working fine, now as soon as i changed the layout from 2*2 to 4*4, the view gets changed, then later on the dragged camera remain same on the canvas, but the streaming coming from the camera initially stops and then starts, i just want the video stream coming from the camera to remain consistent, without restarting it, what i have did now, is to release the Media player , Created the updated Canvas and Add it into the panel, but i guess it's not a proper solution, can anyone help me out with this issue, thanks well in advance.
Any kind of help is highly appreciable.
You can not remove the media player Canvas from the frame component hierarchy, nor can you hide it.
You must do something else like minimise it's size to 0,0 use a custom layout manager and move it's position to 0,0 or -1,-1 may work.
To emulate hiding, you could use a CardLayout with a video view and a blank view and switch between them.
There's an example in the vlcj test sources that shows one approach: https://github.com/caprica/vlcj/blob/master/src/test/java/uk/co/caprica/vlcj/test/layout/AdaptiveLayoutTest.java
I whant to get my home screen to be scrollable to left and right.
I use scene2d and it should be like: Credits screen / Singleplayer screen / Multiplayer screen / Options...
I know how to handle Input don't explain this...
Questions:
Schould i use for every screen a different Stage?
Does it have somting to do with Viewport?
If the home screen gets called does it take long to initialise the stage/s
If 3 is true, how can i load the while an splash screen is displaying?
To answer your questions:
You can, but then the hard part will be a smooth transition between them.
If you only use one stage, you could use the viewport for the scroll animation. I would suggest you to use a ScrollPane though (see example below).
If you don't mess up the implementation, it does not take long.
I suggest you to look at the AssetManager: https://github.com/libgdx/libgdx/wiki/Managing-your-assets
As you can see, there are multiple ways to get such a scrolling screen. I have personal experience using the ScrollPane to achieve this solution.
See: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/ScrollPane.html and http://nexsoftware.net/wp/2013/05/09/libgdx-making-a-paged-level-selection-screen/
Hi i'm looking for a way to animate these little icons i have for an app i'm making. basically i want 3 little icons to slide from the top of the portrait android screen to the bottom continuously and randomly. I have searched a lot so sorry if this is a repeat but i just cant quite find anything i can understand. So far i have Nothing except the images and xml set up. If this is already answered can someone please point me in the right direction. Is there a way to go about this in xml or must i use java? also would it be easier to use a framework such as libgdx with box2D?
you can use surfaceview and making your whole screen as a canvas whereas you need to control your objects' position every millisecond, another option is using the Animation in android, you can refer to this link it is sliding from left to right and vice versa
Goal: A highlighted section of an image (the image covers the whole screen). The rest of the screen needs to be faded out.
Example
So far I've got the fading working using the foreground of a FrameLayout and placing the image as the background of a RelativeLayout within the FrameLayout. The solution I'm thinking is that I need to create 2 Drawables and merge them into one that FrameLayout Foreground can consume.
I've also been reading a bit up on PorterDuff, but I think that may be overkill for what I'm trying to achieve.
The fade functionality is working fine, but the source of the fade with transparent section is not.
I suggest that you have the original image in an ImageView on top of it place 4 views which are partially dimmed and that's it!
With some basic math you can know the sizes for each view, and using RelativeLayout will allow you to easily place them on the screen.
Good Luck!
P.S. I've attached a sketch to illustrate what I'm suggesting.
I have used SurfaceView in my game. Right Now, I have created layout considering one device (320 x 480). The game layout looks nice and all functions are working properly. But when I see the same game in another device with different dimension (screen size), the layout does not seem to be proper.
So is there any property, method, formula or helping Tutorial by which I can create game design/layout through canvas which looks same in all screen size devices.
There is one simple hint: don't ever use absolute coordinates on the SurfaceView. Every item's position should be calculated at runtime depending on the actual screen size. This way you'll achieve a layout that will look the same way on every device. Hope this helps.