I am starting to develop an android trading card game, I have love to ask a couple of questions and recieve some feedback from more experienced developers, lets get on with my questions.
1 - How can I create a board where I can lay cards down? like really I have no idea... maybe fill a simple 'xml layout' with a background image that already has the fields where the cards should be.
2 - How can I implement a way for the cards to listen for like drag from my hand and drop in the field.
Even if I will draw the frames already inside a background image, how would the cards sit exactly in these frames?
Tips? ideas? anything that comes in mind will really help me!
1- You can use some ImageView/ImageButtons to show the cards. Using a relative layout you can show the cards in the position you want (even overlapping)...
2- For the movement, you can drag the image to a zone that you define. This post can help you with that: how to drag an image by touching in android?
Hope it helps ;)
Related
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
I'm not looking for a tutorial or anything, I just want a better understanding of how the view on the phone screen changes with respect to a character within a larger area. I made a crude picture to help my lack of articulation.
How would you move where the phone is viewing, I don't even know how to word it, my mind can't grasp the concept.
Let me try to articulate your question by using an example:
Lets say you are developing Mario bros. Now the entire level (black box in your picture) is when the level starts till mario reaches the castle (entry to next level). The red box is whatever part of the level user can see on the screen. Now you want to know how to achieve this (right?).
Although I am not a game developer, but the simple logic that comes to mind is that you just have to move the level (background) image to left when the player moves right (actually player is at the same place) and if you want to generate a 2D depth effect then you'll have to use something known as parallax scrolling
Following this link might help you in developing such games
I have some C# experience, but im completly new to java. So i have some questions for someone with more experience.
I would like to draw a simple game board of for example 10x10 grey boxes. So i figured a 2d array might be useful:
int gameBoard[][] = new int[10][10];
For each board i would like to draw a grey rectangle, and place it it some control to be rendered on the device.
I suppose this can be done with an instance of Paint and Canvas
And this is where im stuck at the moment. What controls are best suited for this? Any help is much appreciated.
Take a look at this link, it explains very clearly the differences between canvas, paint and bitmap and finishes with an example of an app that draws a colored rectangle and displays it in an ImageView. Hope it can be useful.
Better use GridView or TableView for the box structure. Further , if you will wand something to crawl over boxes, it will be another activity on the deskboard one. There you'll maybe use bitmaps. THis way you will save heaps of time.
I would probably go with the TableLayout, which I guess is what Gangnus meant with TableView
There is a tutorial for TableLayout here:
http://developer.android.com/resources/tutorials/views/hello-tablelayout.html
In your case you would put 10 views in each of 10 rows. You can chose to create them in the xml file or from the java file.
I'm starting work on a game, with the majority of all actions taking place on the 4x3 board in the middle of the screen.
As far as Android is concerned, what would be the best way to go about implementing said board? I was considering GridView, but that seems to be more focused on being a list of items than an actual board. I need to know the coordinates of pieces on the board, and not every space will always be filled. Can anyone point me in the right direction?
Try TableLayout.
Tutorial: http://developer.android.com/resources/tutorials/views/hello-tablelayout.html
My group project at school is to implement a style of monopoly in which students can buy courses and land on various squares and move around the board. This is not a regular square board so we were wondering if anyone had any ideas on how we would implement an image map or something like it to create many clickable regions not in a perfect square. I have attached the image of the game board. Just a way to start is needed, not lots of code or anything as we all know java pretty well. If anyone has any ideas that would be great.
Image of board is here.
Java image maps can have polygonal clickable regions. As usual, Sun has an excellent tutorial.