Corona SDK - Combining Group Objects - lua

I'm developing a game in Corona SDK!
My game loads rooms individually and then places them side-by-side to make a full map. Each room is its own Display Group made with display.newGroup(). I used the opensource library ponyTiled to do most of this.
There is a minor problem though: All objects placed in the second room are put in FRONT of all the objects in the first one. That includes background, NPCs, Walls, floor tiles, etc. I tried using object:toBack() to move background tiles backwards, BUT since the rooms are separate display groups, they don't effect each other!
SO! I need to know how to combine display groups so I can use object:toBack()! How do I do that?

You can add display groups inside other display groups. For instance, sceneGroup is just a display group.
If you were to add the display groups that you want to order inside the same display group, like the sceneGroup, then you can use the group:toFront(), group:toBack(), etc. function calls.

Related

Display objects on a SCNScene according to their distance from the user

I am creating an app in an AR environment which shows interesting points around the user. I can add and show all created nodes but I don't get the thing on how to manage their display if they are close the the user.
Ideally, I want to show objects within the 5 meters around the user,
how can I perform that ?

A-Frame & ar.js: Multiple markers & boxes

Is there any proof of concept of how to implement multiple AR markers w/ A-Frame?
Ex. Something like this: https://www.youtube.com/watch?v=Y8WEGGbLWlA
The first video in this post from Alexandra Etienne is the effect I’m aiming for (multiple distinct AR "markers" with distinct content): https://medium.com/arjs/area-learning-with-multi-markers-in-ar-js-1ff03a2f9fbe
I’m a bit unclear if when using multiple markers they need to be close to each-other/exist in the same camera view
This example from the ar.js repo uses multiple markers but they're all of different types (ie one is a Hiro marker, one is a Kanji marker, etc): https://github.com/jeromeetienne/AR.js/blob/master/aframe/examples/multiple-independent-markers.html
tldr: working glitch here. Learn the area (the image is in the assets), click the accept button, and toggle the marker helpers.
Now, a bit of details:
1) Loading saved area data
Upon initialisation, when ar.js detects, that you want to use the area marker preset, it tries to grab a localStorage reference:
localStorage.get("ARjsMultiMarkerFile")
The most important data there is an array of pairs {markerPreset, url.patt} which will be used to create the area.
Note: By default it's just the hiro marker.
2) Creating an area data file
When you have debugUIEnabled set to true:
<a-scene embedded arjs='sourceType: webcam; debugUIEnabled: true'>
There shows up a button "Learn-new-marker-area".
At first glance it redirects you to a screen where you can save the area file.
There is one but: by default the loaded learner site is on another domain.
Strictly speaking: ARjs.Context.baseURL = 'https://jeromeetienne.github.io/AR.js/three.js/
Any data saved there won't be loaded on our website, for local storage is isolated per origin.
To save and use the marker area, you have to create your own learner.html. It can be identical to the original, just keep in mind you have to keep it on the same domain.
To make the debugUI button redirect the user to your learner html file, you need to set
ARjs.AnchorDebugUI.MarkersAreaLearnerURL = "myLearnerUrl.html"
before the <a-marker>s are initialized. Just do it in the <head>.
Once on the learner site, make sure the camera sees all the markers, and approve the learning.
It should look like this:
Once approved, you will be redirected back to your website, the area file will be loaded, and the data will be used.
As #mnutsch stated, AR.js does what you want.
You can display two different models on two different markers. If the camera doesn't see one of the markers the model vanishes (or stays where it was last, depending on your implementation.
The camera doesn't need to see both.
Screenshot:
https://www.dropbox.com/s/i21xt76ijrsv1jh/Screenshot%202018-08-20%2011.25.22.png?dl=0
Project:
https://curious-electric.com/w/experiments/aframe/ar-generic/
Also, unlike Vuforia, there is no 'extended tracking' - once the code is out of sight, you can't track anymore.

Making a simple scoreboard with sprite kit

So I have seen some totorials around that tell how to make a scoreboard using the Game Center API. Don't get me wrong I love the idea of Game Center, but I dont want my users to have to fuddle with logging in and I dont want to use their way of displaying scores because it does not match the style of the game.
Does anyone know of a better way to do this so I can decide how to display the scoreboard? All I want to do is tell the user his numerical rank like "rank: 1054", and then display the top 100 users (each user has their best score up). And then if I could just have an array with a string for their name, and numbers for their score. I am fine using the Game Center API as long as I dont have to use it for displaying it.
Also is their a way I could make like an "int" that is stored on Game Center that keeps track of how many times the play button has been pressed for all users? Thanks much!

iOS Google maps dynamically update/remove programmatically created markers

I am stuck with some lack of xcode / iOS programming knowledge.
I have created a track in google maps for iOS, and programmatically created markers along this track. What I would like to do is update these markers with actual information in the .title / .snippet (ie. distance to go, time to go etc) or remove them all together.
But when you create markers in a loop there is no way of keeping track of them.
since the amount of markers can vary from 2 to 50 it would be strange in my opinion to create 50 different variables for each marker, I guess there must be another way?
You can keeping track of created markers.
Each GMSMarker has property userData. You can add some string tag or other custom object to identify this marker.
e.g.
marker.userData = #{#"key" : #"some tag"};

Dynamic Tile Map possible with Cocos2D?

I want to be able to load a list or an array of tiles and displayed them on a map.
Cocos2D offers a possibility to load tiles on a map. But for my case, I have to load just a specific part/range of tiles (which I define) and this changes dynamically during the run time. I never want to load the whole map at once. Is this possibile? Maybe an alternative to Cocos2D on iOS? The map details come from a server. It should be done in a quite large multiplayer environment, that's why each player/client should only load his relevant parts of the map.
You can definitely do this, and there are many different ways. For example, swapping scenes or layers during run time, with different tile maps on them, or by creating tile maps your own way with a custom set of methods using CCSprite (for example, it is common to create your own parallax scene instead of using the built-in Parallax scene methods in Cocos2d, and you could do the same with tile maps, if desired). The options are really limited only by creativity.

Resources