I am working on converting some of my games to android after already publishing them to the IOS App store. I wanted to add a little motion to the objects on the screen. In Spritekit, you can simply use the following to move a node a certain length:
Node.run(SKAction.move(by: CGVector(x,y), duration: time))
This is very useful for giving motion to stuff on the screen and wanted to replicate it in Java. Does anyone know how this can be done?
Unfortunately, it is not that easy to move objects in Android.
There is some difference in iOS and Android, where iOS provides easy to use framework, Android doesn't have any easy to use native framework.
Now how to do it, in Android?
First let's learn some basics:-
iOS has SpriteKit, Android has Canvas
SpriteKit can use concept of Node to display object on screen.
Canvas uses bitmaps to draw objects on screen.
Now, it is too big of a topic to cover on Stackoverflow, but the general things, we need to do is:-
Draw objects on screen, where they should have been initially
Then we have to setup game environment is such a way, that the game runs in a while loop, and which should atleast give user, 60 FPS.
Then add the move object logic, inside the while loop. Thus, giving the user, the illusion that the object moved (2, 6) position in 10 seconds.
I would literally just show you the code, which does that https://bitbucket.org/jenelleteaches/android2d-pongclone/src/master/MainActivity.java
And would recommend reading this book, before moving into 2d game development in Andorid :- Android Game Programming by Example. This is published by Packt
Related
So I have come up with an idea for a .io style game using java. (I know it isn't actually a .io, that's just the domain that is commonly used.) I would like to start out by making a grid and I have tried with JFrame and JPanel etc but I think im barking up the wrong tree...
Anyone got any useful advice in terms of making a game "space"/map? I'm a fair beginner but I'd be OK with a not-too-in-depth explanation, just want a a good point in the right direction. And yes, I know the IMMENSE amount of work that goes into the multiplayer networking and everything else like that but I just want to get the game up and running as a single player to start with.
I think other people would appreciate a decent answer to this question aswell...
Thanks!
Can you use JavaFX? They have a GridPane which might be what you want. If all you want is a grid-like background and not an actual grid like slither.io then I believe you can just draw an image to background. You can (should?) also use OpenGL. If you plan to use OpenGL then you can use LWJGL or a game engine like libgdx
You would have a much easier time doing this in JavaScript using an HTML5 canvas. You could even use the Socket.io framework for handling all the networking. There's tons of tutorials for that stuff on YouTube, and switching to JavaScript is stress-free. I learned the general syntax in under an hour after coming from Java/C++.
Im in this situation, I have an ADF with some 3D object on it (I have the positions of objects saved on DB), now what Im doing is loading ADF,waitting to LOCALIZE and putting 3D objects on it but every time I run the app object appears in different places and I noticed that this depends on the orientation/pose of smartphone when it starts, so in few words how to take in account device pose/orientation and put 3D object in Rajawali3D(graphic engine) with respect to that pose?
Under Unity I had the same problem, I fixed it by checking the "Use Area description" in the Tango Pose Controller prefab. What this does, is that it changes the Frame of reference that Tango is using to localize itself: indeed instead of TANGO_START_OF_SERVICE you need to use TANGO_AREA_DESCRIPTION as a base reference frame.
Hi I am currently developing a game for android on unity. (2d game)
I've been looking for answers everywhere since a week but still no answer ... So I decided to ask here.
Actually my problem might be very simple but I am new to Android development and I had no idea of how it was walking.
1 - I want the input field right at the top of the keyboard to be hidden, to put a custom input field made with unity UI system.
2 - Adjust keyboard's position (Only for like 50px from the bottom of the screen) so that i can put my stuffs in there.
I get that keyboard appears automatically when an InputField is focused or selected. But it dosen't make disappear the input field from the native keyboard.
From what I learned serching , I get wether I need to make plugin for unity or export my unity project to eclipse to do so.
But unfortunetly I have no base on java or xml.
I should really learn at least basic skills on these stuffs but for now I can't afford to spend time to learn from base.
What would be the most easy way ?
Hope someone can help me out.
Thank you !
Maybe you can change the input field to just text,
And when you click on the text, show your own keyboard ui.
This is an alternative solution I think.
I am developing a small desktop application in Netbeans. The application is complete and working fine. A small description of application is as follow:
The application is basically an object manager, where user add new object, remove old objects and connect object with each other. What i did is that i simply add 3 panel and change its type to titled border. One for Add object one for remove and one for connect.
Status:
Every thing is working fine as expected.
What Left:
In order to make UI more appealing i added a new panel at the end and called it "Object Viewer". I am planing to visualize the steps which user performs e.g
If user add an object then i that pannel i will daraw a little
circle and fill it with green color
Similarly if user remove some object then again i will draw another
cricle and fill that with red
And when user connects two object then i will draw two circle and
connect them with a dotted line
This is my first java application, i only want to know how do i acheive this task. Some links or experience are highly appreciated
As for custom painting in swing, have a look here: http://download.oracle.com/javase/tutorial/uiswing/painting/
However, I'd suggest using a graph visualization library like JUNG etc. Using this you'd basically only have to define your object graph.
You can either do that manually with Java 2D, which I don't recommend, or, since you are using Netbeans (and I assume the Netbeans Platform, but this is not required), I would strongly suggest looking at the Netbeans Visual Library. It can do exactly what you want.
As Nico Huysamen said you can do that with Java 2D. But because it's your first Java application I strongly recommend to do it manually with this lybrary in order to understand how higer level lybraries work.
...similar to those produced by email clients like thunderbird or outlook, sliding up or fading in from the tray.
The simple popup: Look at http://jtoaster.sourceforge.net/
For the fancy stuff look at what Java 2D can do:
http://java.sun.com/products/java-media/2D/samples/java2demo/Java2Demo.html
Check Composite -> Composite FadeAnim.
What are your notifications for? Is it for a program that already exists, or are you writing a new application?
I ask because Adobe AIR has some functionality for doing this sort of thing, either as a Flex based application, or an AIR application written in HTML/JS. But, you wouldn't use AIR unless this is something you were building from the ground up.
Swing's Timer class (http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html) can be used for rudimentary animation - just use the timer to update the location of the panel containing your content.
I attended a JavaOne session last year where they did some pretty slick stuff with this.
Slides : http://progx.org/users/Gfx/FilthierRicherClientier.pdf
pay special attention to page 29 and on.
And here's a website from the same folks, but with more code and screenshots, etc...
http://today.java.net/pub/a/today/2007/10/23/create-moving-experiences-with-animated-transitions.html
The end result of all of this was very, very slick.