AndEngine astar pathfinding - android

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.

Related

Render image using srcset property in React Native

I am having following JSON feed from one of my Wordpress blog, and I would like to render images within the content of the blog as the JSON feed shows.
There is only one image in the feed, however you will notice one tag and within that a few srcset as well. For some reason is giving a relative URL which is no good for me to render an image outside of the Wordpress blog, however I could use the property of tag which is srcset which is providing an absolute path to the image.
Could someone suggest me how I can ignore the src of the tag and rather should be able to use srcset? The platform I am using is React Native.
<p>Can you spare a few minutes to look at some terrible and completely ridiculous life tips? Well then you’ve come to the right place!</p>\n<p>Some of them come from a sub-Reddit called /r/ShittyLifeProTips, and while they won’t actually help you to achieve much, they are at least useful when it comes to making us laugh. From using ketchup as a bookmark, to saving yourself precious time by adding toothpaste to meals, these “pro” life tips are sure to put a smile on your face while completely failing to help you in any practical way.</p>\n<p>P.S.: These tips are a joke and may be dangerous, don’t try them yourself!</p>\n<p><strong>#1 Use a toilet seat to put your plate on while watching TV</strong></p>\n<p><img class=\"alignnone size-medium wp-image-2098\" src=\"/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg\" alt=\"\" width=\"284\" height=\"300\" srcset=\"https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg 284w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-545x575.jpg 545w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV.jpg 605w\" sizes=\"(max-width: 284px) 100vw, 284px\" /></p>\n<p> </p>\n

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.

Get a (Android.Graphics) Path of a String

I cannot find any way to retrieve a Path object representing a string. Does it exist? A list of the necessary points would be enough, but I guess, internally, a path is used.
For example in GDI+ there is:
GraphicsPath p = new GraphicsPath();
p.AddString("string");
From there any point of the "drawn string" can be accessed and modified.
PS: I do not mean drawing a text along a path.
I've spent quite a long time solving this problem (to draw vectorized text in OpenGL) and had to dig deep into libSkia sources. And it turned out pretty simple:
Indeed, canvas uses paths internally and it converts text to vector paths using SkPaint's getTextPath() method. Which is, luckily, exposed at Java side in public API as android.graphics.Paint.getTextPath(). After that, you can read Path back with android.graphics.PathMeasure.
Unfortunately, you can't read exact drawing commands, but you can sample the curve pretty closely using something like bisection.

andengine tilemap respawn

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.

Cocos2d Android CCRenderTexture example

CCSprite texture1 = CCSprite.sprite("menu_background.png");
CCRenderTexture layerRenderTexture = CCRenderTexture.renderTexture(width, height);
layerRenderTexture.begin();
texture1.visit(CCDirector.gl);
layerRenderTexture.end();
this.addChild(layerRenderTexture);
I haven't seen any CCRenderTexture example on Internet. When I try to use it as above, I expected to see a nice background. Instead I see black :)
What am I doing wrong?
Thanks for your help.
I haven't seen any CCRenderTexture example on Internet.
I think you may have been looking on the wrong Internet? :)
Check out my article and Ray's article. Both come out on top when you google for CCRenderTexture. They use cocos2d-iphone, but the same principles apply.
In your particular case I don't see you adding the layerRenderTexture as child to the scene or another node. That would explain why you're not getting any results.

Categories

Resources