Android Tutorial Introduction to the libGDX library

shashkiranr

Active Member
Licensed User
Longtime User
Hi Fred,

I am using texture to initialize a image and then calling Batch.DrawTex2 to draw the image as background in a live wallpaper application and it is working fine.

I want to change the background image. So after copying the image into internal folder how to reinitialize it to the texture? If i use

B4X:
Texture.InitializeWithFile(LW.Files.internal("SelectedImage"))
it is not working. tried to initialize with Pixmap but dint work.

Also need a suggestion as to in which sub i can add this code ( LG_PreviewStateChange or LG_OffsetChange or LG_Resize).

Regards,
SK
 

Informatix

Expert
Licensed User
Longtime User
Could you post a project showing what you want to do?
 

JEG

Member
Licensed User
Longtime User
Using B4A I have converted a simple colored polygon map of Farm fields, running in ms Access/Windows to run on a tablet using sqlite/XML/SVG. This works well on a few polygons, but is unacceptably slow for 50 and fails at about 300. The map I have has some 700 polygons


LibGdx example Perf_PloyTree runs a 1000 polygons at some 30 f/sec


I have looked at using this. Rendering unfilled polygons is simple but I have been unable to get lgMathEarClippingTriangulator to work.


Any advice/examples on rendering filled polygons in LibGdx or in some other library would be appreciated.
 

Informatix

Expert
Licensed User
Longtime User
It's the kind of message that can't get an answer because it is too vague and does not explain the used method. And what is the problem with lgMathEarClippingTriangulator? (note that I fixed a bug in this class in the latest release so your problem is maybe gone).
 

mjas

Member
Licensed User
Longtime User
Hi, very good work you have done with this.
I'm trying to create a simple child game and have an issue: how to populate an "lgScn2DSelectBox"?
I tried in both ways: on "Initialize" or in "Items" by giving an array of strings, but always get the same error: "items can not be null".
Can you help on this, showing an example of how to create this list of items?
Thank you
 

Informatix

Expert
Licensed User
Longtime User
It works this way (and you can see that working in the Scene2D_Lists example) so you probably do something wrong when you fill your strings array.
 

mjas

Member
Licensed User
Longtime User
Thank you for the answer.

And I'm doing it right, but the result is always the same. I tried the example "Scene2D_Lists" and it's ok. Then if i give a null background to the style applied to the SelectBox of the example it gives the same error. After all the error is not null items, but null background.
Strange...
But now that i know it, I'll see what happens with my background.

Thank you again for this great library.
Best regards.
 

Informatix

Expert
Licensed User
Longtime User
ListStyle and ScrollStyle cannot be null. They have to be set after initializing the SelectBoxStyle. I will add them to the parameters of the Initialize function in the next release.
 

JEG

Member
Licensed User
Longtime User
Sorry about insufficient detail. In the attached Dim w() as float gives a compile error "Required float[] found Short Array". What needs to be done
 

Attachments

  • B4A query1.txt
    972 bytes · Views: 346

noclass1980

Active Member
Licensed User
Longtime User
HI, I tried the Physics Body Editor to create the body but when it is used in my app, I can see the consructed polygons overlaid on top of the image. Can anyone suggest why this is happening?
 

noclass1980

Active Member
Licensed User
Longtime User
Yes i did! I hadn't appreciated that the debug renderer was causing the "problem". All sorted no and thanks once again for the helpful advice.
 

soce

New Member
Licensed User
Longtime User
Hi
About Multiple screens
Can I put events(Show,Resize,Render,Pause,Resume,Hide) in the class?
 

Carcas

Member
Licensed User
Longtime User
Hello to all

I have some questions from beginner

I tried perf_smile example on three different devices, and I have these three values of "FPS" with 25 smileys:
nexsus7 = 60FPS
HUAWEI Y300 = 60fps
SAMSUNG GALAXY YOUNG = 80 FPS

First question is:

it is possible that an inexpensive device like Samsung Y (density = 0.75, scrensize 320X480) has a "FPS" so high?
This difference depends on the density? (80 * 0.75)= 60?

Second question is:

I would like the speed of the smileys is the same on all devices.
it is correct to set the speed in this way?

velocity = 2dip* (60 / lGdx.Graphics.FramesPerSecond)

(without considering the scale)

thank you
 

Informatix

Expert
Licensed User
Longtime User
it is possible that an inexpensive device like Samsung Y (density = 0.75, scrensize 320X480) has a "FPS" so high?
This difference depends on the density? (80 * 0.75)= 60?
FPS = frames displayed per second. No relation with density, pixels, resolution, etc.
Devices are usually capped at 60 fps, but not all. With only 25 smileys, your FPS value is just the best FPS you can get with this hardware; it does not mean that's a fast device. Try with 400 smileys and the result should be very different.

I would like the speed of the smileys is the same on all devices.
it is correct to set the speed in this way?

velocity = 2dip* (60 / lGdx.Graphics.FramesPerSecond)

You have to express the speed of your sprites in %x (or %y) per second if you want exactly the same proportion of movement on different devices with different screens, so your formula is wrong (and I can't see any use for it as you suppose that all devices run at 60 fps). You can see an example of formula in my tutorial about games.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…