I have 2 images of legs of a character, I want them to be changing while I pressed the keyboard for example left or right arrow key. It's like the character is walking. How to do this in java slick2d? I have no codes to provide because I have no Idea how to start coding it. Thank you very much.
If you just want to handle basic input and you don't need to use slick2D then you can just use a KeyListener or MouseListener for input. These are Java features and are very simple to use.
To use Slick2D, my best guess would be to start here,
Slick Commands
These are for more advanced inputs I believe but you should do some research on each to see what you need to use.
Related
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 want to write an address in the address bar of a browser as well as click on a link using java Robot class. How can I track the different objects in a certain window?
Just giving a look at the API http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html, anyone who do this should know that via Robot Class there is no "trackComponent(Component specificComponent)" method, you got 2 things that may help you:
1-getPixelColor (more than help, seems useless for you by now, maybe i'm wrong).
2-createScreenCapture.
the second method is maybe the answer for your problem, you could take a picture of the screen and with some image processor (javaCV could help you on this: https://code.google.com/p/javacv/) you could then track the components on the screen you took (for instance: from pixels xxx to pixels yyy is the Address bar of browser), of course you need to read some documentation about javaCV (OpenCV) for get this done, after that just use the method for move cursor and enter keys for fill the components, hope someone give a simpler way to do this, but i think this way you learn a bit of JavaCV a really powerful tool.
So, I converted a game to Slick2D. The movement is broke, and I am at a loss. Before, we used KeyPressed and keyReleased methods, but now with Slick2D movement isn't working right.
Yea, nothing has gone right with converting to Slick2D. First the launcher, which I had a help topic on before, and now this. Though, the other topic was an issue with WebStart hating code.
You can only move right, using A. And you can't stop moving. Am I using the right methods? How can I fix it? Any help is greatly appreciated!
Here is a PasteBin link to the code, if it helps! http://pastebin.com/GRH86Yuw
I'm a fan of Slick, and I'd be happy to help.
The fundamental difference is that Slick is a polling model, not an event-driven model when it comes to input. Basically, in your logic update method you loop through the keys bound to your events, and check to see if any of the keys are currently pressed, and then trigger those events. For a number of reasons that I can go into if you like, polling tends to work better for games, especially with a large number of keys. It's just a different way of doing things, an not that complicated. The biggest upside is that you get centralized input processing a single method, instead of having it spread across multiple KeyListener instance objects.
If you want to look at Pedestrians - a simple pedestrian sim implemented in Slick - you can see an example of how to handle input in Slick.
Specifically, I handle input in this file (lines 192-295), inside the processInput method. Basically, you pass in a reference to the GameContainer object (the Slick object that contains your game), and from that you can get an instance to the Input instance that will allow you to check which keys are pressed, what mouse buttons are clicked, etc.
I'm starting to create a Industrial Simulation (IS) interface, using Java.
The problem I'm pointing here is the interface.
A IS interface will have some big squares (geometrical figure) (unfilled, instead of it they will have their "names" inside it), one or more lines linking the squares, and while time will be going, some "mini-squares" will get out of one big square to another, following the line that links both.
I have to construct a interface that is able to have either the geometric (square) figures and the animation with the "minisquares" following the link (that will be the line).
Is there any API, or tool, whatever, in java, that could help me starting this part of the project?
If you can use javafx... runs on the JVM... that might be easiest way. Here's a link to a tutorial for animating along a path
Otherwise I guess you'll be looking at Swing, but I suspect it's a lot trickier. Here's a similar link.
Visual editors like Matisse can help you get started with layout etc., but I don't know of anything that will let you point-and-click your way round animation.
I will explain my question clearly.
I need to zoom in/zoom out the world map.
When I click on the particular country in map, control should redirected to new page with respective the country.
I dont have any idea about this in java. Please explain the steps to acheive the above task.
As the question is quite general, here is a general answer: Zooming often means, that you want to display a certain percentage of somethin, and not the whole, where your size of the displayed will not change.
But in your case it seems more like a "find a mouse click in a polygon" thing. So you have to add a selection/click listener to whatever widgets you use (Swt? swing? ....?) where you change what your program renders.
It sounds like you may be trying to reinvent the wheel. Google etc have already solved this problem rather well. It might be better to incorporate an existing solution into your application. Have a look at GoogleEarth inside Java Swing.