Million Tile Engine Beta Release

Hi Dyson,

What an update!! Many thanks for your work on this! The inclusion of touch scroll / pinch before the 1.0 release was a great surprise so many thanks for this! Storing the color value for tinting/lighting is also going to be a huge help to me and means I can now look at including lighting effects in the future. This is all great and many thanks again.

Color

Like John I noticed the use of graphics 1.0 colour values (0-255) rather than 2.0 (0-1) and agree consistency with 2.0 would be very helpful (even though I personally prefer the old 1.0 value system).

Touch

I also wondered: would it be possible to include some custom events in the touch scroll / pinch code? Something like…

Runtime:dispatchEvent( { name = "mteTouchBegan", data = {} } ) Runtime:dispatchEvent( { name = "mteTouchEnded", data = {} } )

… (where “data” is optional and whatever you choose to include). It’s just that in my current code I’ve added these events and it allows me to pause certain game elements and trigger others based on the fact the camera view is no longer focused on the player sprite. It would be really helpful if these were included (or something similiar) and I’m sure others would benefit too as at the moment our external code can’t detect when these important touch events have occurred.

Stitching

Finally, I’m looking forward to seeing the map stitching in action and wondered if you could answer a query. I’m considering a game where the map is randomly generated and the idea is to stitch together selected preset mini-maps (composed in Tiled) to dynamically create a unique larger game map and experience each time. I’m thinking each mini-map would be a grid of 9 tiles (3 x 3) and the final stitched map could be comprised of any number of these (let’s say 30 x 30 stitched mini-maps). Would something like this be possible with the new stitching algorithms? Do you envisage any performance problems in doing this? Could sprites regularly, quickly and efficiently move from one mini-map to another, with smooth movement transitions, given your implementation? This really would be fantastic if possible.

Many thanks again!

Congrats, dyson, it’s finally out :slight_smile:

I will be trying it out in the next few weeks. But I am still in a learning curve and probably not going to help much in finding bugs. If I do find any, I will let you know of course.

Thanks for your hard work & exciting upgrade.

Hi Dyson,

I’ve just about got my head around storyboard scenes now but when I look over your example code with storyboard used your first scene is willEnterScene in the two examples (IsometricStoryboard and RotateConstrainStoryboard) rather than createScene.  I can’t find any references online to leaving out the createScene so I’m wondering why you do this and what the are benefits or otherwise?   It certainly doesn’t seem to cause any issues from what I’ve seen so far.

Thanks.

Hi Dyson,

another query I’m afraid.  I just decided to upgrade from  version 958 to 984.  In my code I’ve used the following for some of the touch control work  " scaleFactor =  mte.blockScaleX / mte.worldScaleX.    "

Re-running my code with 984 threw up errors as neither  mte.blockScaleX  nor  mte.worldScaleX  seem to exist any longer.   I’m guessing you’ll need to be doing something similar in your touch control implementation but I can’t be sure what the correct variables I can use from mte to replace these.

I will look at using your touch implementation, which is a great idea, at some time but at the moment I’ve got mine working exactly as I need so I’m not keen to change it at this stage.

As your code is now almost out of beta and you’re focusing on documentation more can I make a request that you issue some release notes showing what’s changed?  For instance, where functions or variables are renamed/ altered /deprecated in some way.  I had a similar issue recently when I discovered that mte.goto had changed name (I know for good reason) and it took some hunting to understand why it had gone and what the new function was called.

Thanks

Hi dyson,

Now that I updated to the new Mte v 0980, I noticed that objects I made in Tiled with physics properties will only work half the time(i’m making static walls) and set in hybrid mode I can see that the physics turn off when my character moves in certain places on the map.  I figured maybe this has to do something with the offscreenPhysics so I added this property to true and I noticed that it works now. Does mte know how many tiles are on screen or do i have to specify this? Not sure if this is a bug or not or whether Its my setup. 

Also, this doesn’t have to do with the update. If I have a tile which has transparency(maybe a ball for example) the areas which should be transparent show as white when my game is loaded. In the tiled editor it looks fine. Is this something to do with tiled properties?

A quick question,

Now that I’ve enableTouchScroll(), I can’t just touch a spot on the map and have my sprite move there, how do I differentiate between touch to move a sprite vs touch scrolling?

(I currently use Runtime:addEventListener(“touch”, mtemove) to call my moveto routine)

Thanks, Greg

The .color property is not a temporary fix, rather it is a workaround for the SDK’s lack of a getFillColor property. The engine has no way of looking up the fill color of an object. When the lighting system tints an object the original tint is lost forever unless it is stored somewhere by the user. The new .color property fills that need. Whenever lighting is in use the developer must use .color if he or she wishes to change the tint of an object. 

If I’m wrong about the lack of a getFillColor or functionally identical function than please let me know! It would do away with the need for a developer to set .color manually.

All that being said, I’m still trying to nail down exactly what the default behavior of MTE should be in regards to lighting. Sprite’s are lit based on their lighting parameter, a simple boolean. At the moment the default setting is true; any tinting will be lost unless you set .color. If you set the sprite’s lighting parameter to false the engine won’t overwrite your fill color and you can tint the sprite manually using Corona’s native functions. 

Do you think lighting’s default should be false instead of true? Or, perhaps, “vector” sprites could default to false while others default to true? Feedback is welcome!

I used the 0-255 range because MTE uses this internally and still requires this range when using Tiled properties to set Tiled Object colors. But you guys are right about it causing confusion. I’ll go through the engine and samples and bring everything up to date with the new 0-1 range this week.

AppDeveloperGuy;

Yes, I can add in those events. That’s easy enough.

What I hope to accomplish with the new map stitching feature is the seamless expansion of a map. Using a function similar to loadMap, you will specify what map you want to load and where in the pre-existing map to place it (including outside of the current bounds). If any part of the new map is outside the current map bounds the engine will increase the size of the map table to accommodate. It will then load the new map tiles directly into the current map. It will also loop through all the Tiled properties and tilesets in the new map and attempt to merge them into the current map’s properties and tileset table. The result is that you won’t have to do anything special when moving a sprite into the new map, because the new map isn’t a seperate object. If you have a 40x40 map and stick a second 40x40 map to it’s right edge, moving into the new map would be as simple as moving to locX = 41. All you’ll have to watch out for is the load time of a map. Loading a large map will cause a noticeable delay in gameplay.

Coldwilson;

I used willEnterScene because there is only a single scene; it is reloaded and reused when the map changes. The scene is never destroyed, so createScene will only ever fire once. What I needed to do is load a new map and sprites whenever the scene was entered- even if it was entered from itself. 

Scalefactor is an old concept which is no longer valid. Actually users were never meant to even see scaleFactor, let alone have to use it. In 958 the blockScale determined the size of the tiles, but the resulting coordinate system did not match that of the map file. If your tiles were 32x32 in size, but you set blockScale to 72, the tiles would be rendered at 72x72. This meant the center of a tile 1,1 on the map was 16,16, but the center of tile 1,1 in MTE would be 36,36. Scalefactor translated between these values whenever the user tried accessing them using an MTE function.

This is not longer the case. The engine scales the group instead of each tile, so a 32x32 tile with ALWAYS be 32x32 and it’s center will ALWAYS be 16,16, no matter how large or small it appears on the screen.

Long story short, you can get rid of scaleFactor. The touchScroll implementation only uses it here:

--Uncomment code block at line 341 to enable pinch zoom / touch scroll if isDragging then local velX = (startX - currentX) / scaleFactor / mapObj.xScale local velY = (startY - currentY) / scaleFactor / mapObj.yScale ...

Simply cut it out as such;

--Uncomment code block at line 341 to enable pinch zoom / touch scroll if isDragging then local velX = (startX - currentX) / mapObj.xScale local velY = (startY - currentY) / mapObj.yScale ...

Documentation has not been my strong point, I admit! I’m hoping to rectify that shortly.

Greg;

Go to line 312 of mte.lua and comment it out; 

return result

Apologies, that was an oversight on my part. Basically, if an object or the Runtime receives a touch event and returns anything (even the boolean true) the touch won’t propagate to other objects.

Hi dyson,  that worked great!,   I switched my sprite move to a tap event so that it wouldn’t move with the map scroll.

Thanks again for the great work, Greg

Hey dyson,

Color: Great stuff.

Touch: Brilliant. Many thanks!

Stitching: This sounds perfect! Very flexible and lots of potential!

I might have missed it but is it possible to zoom in and out programmatically without pinching the screen (I don’t have the api doc to check at present)? I’m planning on adding zoom in and zoom out buttons (or using a widget candy slider) that zoom in and out incrementally to min and max values. Is there any way to set these?

You’ve probably also already considered this but with the recent move from storyboard to composer in the latest public release, if you’re updating the demos and examples anyway it’s probably worth updating to composer too. Like you aren’t busy enough. :wink:

Thanks again as always!

Like you aren’t busy enough.

I know, right? 

Yes, I considered rewriting the current samples for composer, but as usual it came down to a time budget issue. There’s only so much time and other things like bug fixes had priority. 

You can call mte.zoom(scale, time, easing) to programmatically change the map scale. Alternatively you can retrieve the map object with mte.getMapObj() and use a Corona transition to accomplish the same thing.

Hi dyson,

Right now my character is moving one tile at a time , can i reduce it to 1/2 tile at a time, or any other way to make my character move slowly .

Excellent, thanks.

Hello Trompeta and Kumarks,

The engine calculates the number of tiles it needs to fill the screen at any moment. You can use the cullingMargin parameter of setCamera() to push the edges of the active map region further from the edges of the screen, increasing the number of tiles and allowing physics objects to move further offscreen. Setting offscreenPhysics is your best bet if you need enemies or other important physics objects to move freely across the entire map. If you run debug() in your enterFrame event it’ll display a count of all active tiles.

I’ve never had that problem with transparencies before. Could you post a screen shot and a link to the tileset you’re using Trompeta? 

As for moving the character by half a tile, I believe most of the samples use the locX and locY parameters of moveSpriteTo(), but the function also accepts levelPosX and levelPosY parameters for pixel-by-pixel movement. If your tiles are 32x32 in size, moving a sprite by 16 pixels will move it half a tile. You can also slow the movement down by adjusting the time parameter. 

mte.moveSpriteTo({sprite = mySprite, levelPosX = mySprite.x + 16, levelPosY = 0, time = 500}) --OR mte.moveSprite(mySprite, 16, 0)

Hi dyson,

I plan (at the moment anyway) to continue using addSprite and moveSpriteTo but would like to benefit from the increased performance. Do you have any plans to integrate Corona’s native transition and translation functions in to MTE’s movement functions?

I tried that early on in the rewrite, but I hit a snag I couldn’t fix or work around. Say you want to move a sprite from location to location, again and again, as in most of the samples. For example, walking in any one direction in CastleDemo. The sprite moves smoothly without pauses or breaks in the motion. When you try to accomplish the same thing using transitions, you’ll find that sprite pauses for a frame or two at each tile location. The problem I found is that the transition functionality does not allow a position transition for one sprite to stop and another to start all in the same frame. I worked the problem for a few days, but the complexity of my solution was beginning to outweigh the gain. The code would have been harder to maintain and less flexible than MTE’s current movement system. So, the engine rewrite was designed to allow the use of transitions and translations without using them itself.

If you guys could go to my survey and cast a vote on what you think MTE should cost, that would help me out!
http://forums.coronalabs.com/topic/44769-million-tile-engine-price-survey/

-or

http://forums.coronalabs.com/topic/44771-million-tile-engine-price-survey/

Please don’t answer both of them :stuck_out_tongue: I’m trying to cast a wide net, not get duplicate results!

MTE 0v980-9 - https://gum.co/staO

This update corrects errors reported for MTE 0v980-6, most notably an error causing the camera to “stick” to the edge of a camera constraint in certain situations.

The update also includes a fancy new sample project demonstrating the use of perlin noise and heightMaps; Sledge! Guide the sledge around the mountainous, snowy terrain! Keep in mind that the heightMap functionality built into MTE is computationally expensive. This is best kept to relatively new devices such as the iPhone 5 or Samsung Galaxy S4. 

[media]http://www.youtube.com/watch?v=GnziXEUPogo[/media]

Hi Dyson,

looks amazing on the video.  I tried it on my mac,  it runs very slow for some reason but thought it worth noting that it comes up with this message for us non pro users:

"Your project uses premium graphics features available to Pro (or higher) subscribers. You can view these in the simulator as a demo, but you must upgrade to see them on a device."T

Thanks.

Correction, it runs ok from the Corona Simulator, just very slow when I ran it in LuaGlider.

@dyson

I added  “portrait”, “portraitUpsideDown” to be supported in build.settings

and after I rotate the device (Simulator) to portrait mode, there is a black area at the bottom of the screen that MTE does not utlize. Is there some parameter that I need to set in order for it to work?

PS. I tried with CastleDemo, please see the attached screenshot.