andengine tilemap respawn - android

i'm starting to developt a android game using AndEngine gles2, it's a really good game engine and i found a lots of example of how use it. My game is a kind of RPG traditional game using tiled maps, sprite, etc.: my issue is how i can set a mounster respawn area(like the long grass areas on pokemon games) i read a lots of tile map example but in no one appears examples about this, i using a tiled map editor and there i can set properties to the layers and especify there if is a mounster respawn area or not, if can someone tell me how can i do this i will appreaciate so much.

Are you using the tilemapeditor found here:
http://www.mapeditor.org/
(note, you need to save it with the correct compression type or otherwise andengine will not parse it correctly, cant remember which one I got working but it takes a few minutes to try out).
Then you can rightclick on a specific tile and add properties to it such as:
IsMonsterSpawnArea value = true
Then you can check for "collision" with
if(pTMXTileProperties.containsTMXProperty("IsMonsterSpawnArea ", "true")) {
// SPAWN BIG UGLY MONSTER(or initiate fight!)
}
Check out the andengine TMX examples found in the andengine source, they can really help you get started.

Related

Android ArCore Sceneform API. How to change textures in runtime?

The server has more than 3000 models and each of them has several colors of material. I need to load separately models and textures and set textures depending on the user's choice. How to change baseColorMap, normalMap, metallicMap, roughnessMap in runtime?
after
modelRenderable.getMaterial().setTexture("normalMap", normalMap.get());
nothing happens
I'm doing something wrong. There is no information in documentation for that.
thank you for posting this question.
setTexture() appears to not work: Unfortunately this part of our API is still a little rough; it works but is very easy to get wrong. We're working on a sample to illustrate how to modify material parameters (including textures) at runtime and will improve our error reporting in the next release.
Thousands of models w/ multiple permutations how?: The plan here has two parts:
The binaries used by the Android Studio plugin will be made available for use in build scripts on server platforms. This will allow you to do a server-side conversion of your assets to .sfb. We'll be releasing a blog post soon on how to do this.
The .sfa will get the ability to contain loose textures and materials not explicitly associated with geometry, and .sfa's will be able to declare data dependencies on other .sfa's. This will mean that you can author (and deliver) .sfb's that contain textures/materials (but no geometry) and .sfb's that contain geometry (but no textures/materials), and if they're both available at instantiation time it will just work.
use this code`
CompletableFuture<Texture> futureTexture = Texture.builder()
.setSource(this, R.drawable.shoes)
.build();
and replace with
/*.thenAccept(renderable -> andyRenderable = renderable)*/
.thenAcceptBoth(futureTexture, (renderable, texture) -> {
andyRenderable = renderable;
andyRenderable.getMaterial().setTexture("baseColor", texture);
})
would work.

Displaying KML Layers on Maps at Native Android apps Best Practice

I have big KML file to a native Android application, please check the following details and give an advice.
KML file details:
size: 1.7 MB
total number of kml file elements: 500 elements
total number of polygon: 1000 polygon
Android app details:
the above details will be viewed in Fragment
I used the following support library to implement this screen
compile 'com.google.maps.android:android-maps-utils:0.4+'
some caluctations are done on loading the screens(like distance calculations)
Issue:
Take a lot of time to load the map and kml layer about 8 sec
create KMLLayer instance
What is the best practice to implement the above details with good performance?
please advise.
Best practice is doing long time operation in background (for example, on separate thread) and split complex tasks into small parts. So you can:
1) create and start load KML layer as soon as possible (e.g. on app create) and than just show it;
2) instead of one kml file with 500 elements and 1000 polygons, use 50 kml files with 10 elements and 100 polygons and load to layer only necessary files (for example you can split it by area location, or by semantic information, or by something else criteria);
3) combine 1 and 2 points;
4) precisely for google maps it's possible to create tiles with information from kml files and use TileProvider.
Since there's no actual answer, I'll post my own solution.
I've done mainly two things to optimize this.
Instead of using Google maps utils built-in method addLayerToMap - I've used my own custom implementation. I've done so, because parsing kml is relatively fast(in my case - ~5-10 seconds) and it can be done in background thread. Adding all the points to the map, however, takes more than 10 seconds, and must be done on UI thread. Basically, I've used KmlLayer class as a base, and parsed kml file by myself into polygonOptions and all other things I need.
Calculate which items are visible and which are not. Firstly, I filter which items are outside screen bounds. After that, I calculate each item's size(in pixels, no meters) - if item is smaller than threshold - item is also filtered out.
With these hacks applied, instead of freezing app for 15 seconds, user can freely navigate through map, and when he stops, after several seconds information will be displayed.
I just make some updates on the screen behavior to get good performance and good user experience by the following steps:
Divide the KML File to 65 files (the main areas on the map, for example, Zone A11 is located in one KML file and it contains all its details like Zone A11-1, Zone A11-2 and Zone A11-4 ...) and this division is done to be suitable the screen experience (for example user requirements)
on the first load, I am loading only the markers for all KMLs centers and that is not affecting the performance
When user click on the marker, I am loading the KML file for this area and zoom this area
When user zoom out, I am removing this layer from the map and load marker
When user moves the map I am calculating the nearest marker and load its KML layer
Note: preparing files on app launching will not provide better performance because the bad performance comes from adding the KML layer to the google map
Note2: using custom implementation for parsing and adding to Google map take a lot of time or need a lot of unit testing, and I think it's not recommended solution because it's better to leave this solution to be on Google Map utils build-in method (it's customized and always up to date)
I'd suggest you to make sure that you are constructing the KmlLayer on a background thread and addLayerToMap() has to be done on the main thread though like this
GlobalScope.launch {
val stringUrl: String = "https://saltwx.com/bath/SW_bath6.kml"
val inputStream: InputStream = URL(stringUrl).openStream()
val layer = KmlLayer(map,inputStream, applicationContext)
runOnUiThread {
try {
layer.addLayerToMap()
} catch (e: Exception) {
e.printStackTrace()
}
}}

Need bump map example for libgdx

I'm trying to figure out how to use a bump map. I can add one to a model but nothing happens, probably need to turn on some config option. Please point me to a working example.
I only got this far:
matPlaceholder = new Material(ColorAttribute.createDiffuse(com.badlogic.gdx.graphics.Color.RED), new TextureAttribute(TextureAttribute.Bump, texBump);
You can add it, but the default shader doesn't do Bump Mapping yet.
There are plans of having a composite shader that does that and more. But as far as I know, it isn't ready. You need to write your own shader for that.
There is some good shaders here. Like Normal Mapping. You can give them a try.

How to properly reset a scene in AndEngine GLES-2?

I am developing a game in Android using AndEngine GLES-2. I am facing a problem while resetting a scene after player has completed a level. When I reset the scene, all the sprites lose their positions and tend to appear in each other's positions i.e. they swap their positions.
I have tried all the things like setting all the sprites etc. to null and calling methods like clearUpdateHandlers() and clearEventModifiers() etc. but no success yet.
I found out after a lot of googling that engineOptions.getRenderOptions().disableExtensionVertexBufferObjects(); method can fix this problem. So I am trying to invoke it but compiler gives error saying that this method in not defined for RenderOptions class.
I checked the RenderOptions class in org.andengine.engine.options package and the method really does not exist in that class. Am I missing any plug-in or is there any other problem? Please help, I am stuck.
you need to manually restart the scene, for example:
To restart a Scene you can Finish the activity and Start again but different level with SharedPreferences, or Tag's in intents, or you can set position of each Sprite and cler the Scene with:
//detachChild this Sprites that you do not use
Scene.detachChild(SpriteX);
//clear the space of memory of each sprite that you do not use
SpriteX.dispose();
//unload the bitmaps that you do not use
BitMapsX.unload();
this method have a seconds to run, but you can use a elegant "hud" in you game, and while charging set in the hud a logo or animation with "loading", best regards

AndEngine astar pathfinding

Could anyone give me an example of source code which uses astar pathfinding algorithm with AndEngine on the TMXTiledMap. I am using AndEngine downloaded from https://github.com/nicolasgramlich/AndEngine.
Any suggestion would be appreciated. Thanks!
This is the official TMXTiledMapExample, but it doesn't contain A* pathfinding. It can teach you about tiled maps, though.
Here is another example from the forums which does contain it. It isn't really an example, but the pathfinding code provided there works. I don't think there is any real example of A* pathfinding, never seen any tutorial of it (The best way to learn is to read the code yourself. Better take a look at AStarPathFinder.java code).
The important parts for you in the forum post are are (lines):
123: Initializing the AStarPathFinder
205 - 213: Converting screen/scene coordinates to map tiles and using the pathfinder.
224: The method loadPathFound - using the path returned by the pathfinder to move an entity.
The MyMap class in the third post.

Categories

Resources