Hello Azmar, I’m glad you’re liking MTE so far!
The black line is an edge artifact caused by OpenGL linear interpolation used to scale 2D graphics. If you look at spriteSheet.png you’ll notice that all the sprite animation frames have shadows baked into them. What you’re seeing is the very bottom of the shadow on the the frame above the current animation frame. You can fix this one of two ways. First, you can use a program such as TexturePacker to generate an extruded imagesheet. Extrusion adds a perimeter of transparent pixels around each imagesheet frame. Other than extruding the imagesheet, you can set CoronaSDK to use nearest neighbor interpolation:
display.setDefault("magTextureFilter", "nearest") display.setDefault("minTextureFilter", "nearest")
You could approach spawning/despawning monsters dozens of different ways. This is a gameplay mechanic beyond the scope of MTE. I whipped up a quick-and-dirty implementation to see what it might entail:
--Get the map and set the size of your map regions/screens local map = mte.getMap() local regionSize = 16 --Define your sprites local spriteTemplates = { { "spriteSheet.png", {width = 32, height = 32, numFrames = 96}, { {name = "0", frames = {85, 86}, time = 400, loopCount = 0}, {name = "90", frames = {73, 74}, time = 400, loopCount = 0}, {name = "180", frames = {49, 50}, time = 400, loopCount = 0}, {name = "270", frames = {61, 62}, time = 400, loopCount = 0} } }, { "spriteSheet.png", {width = 32, height = 32, numFrames = 96}, { {name = "0", frames = {88, 89}, time = 400, loopCount = 0}, {name = "90", frames = {76, 77}, time = 400, loopCount = 0}, {name = "180", frames = {52, 53}, time = 400, loopCount = 0}, {name = "270", frames = {64, 65}, time = 400, loopCount = 0} } } } --Create a table for holding the sprites in a given region local spriteData = {} for x = 1, math.floor(map.width / regionSize), 1 do spriteData[x] = {} end --Add sprites to map regions 1,1 and 1,2 spriteData[1][1] = { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} } --Create array for storing active sprites local sprites = {} mte.update() local function gameLoop( event ) --Calculate the current map region local regionX, regionY = math.ceil(player.locX / regionSize), math.ceil(player.locY / regionSize) --If the player has entered a new region if not player.regionX or player.regionX ~= regionX or player.regionY ~= regionY then local time = 1000 if not player.regionX then time = 1 end mte.constrainCamera({ loc = {(regionX - 1) \* regionSize + 1, (regionY - 1) \* regionSize + 1, (regionX - 1) \* regionSize + regionSize, (regionY - 1) \* regionSize + regionSize}, time = time, transition = easing.inOutQuad }) print("Change region:", regionX, regionY) player.regionX = regionX player.regionY = regionY --Destroy the sprites from the previous region if desired for i = #sprites, 1, -1 do mte.removeSprite(sprites[i]) sprites[i] = nil end --Create the sprites for the new region if spriteData[regionX][regionY] then for x = 1, regionSize, 1 do for y = 1, regionSize, 1 do if spriteData[regionX][regionY][x][y] ~= 0 then local spriteType = spriteData[regionX][regionY][x][y] local imageSheet = spriteTemplates[spriteType][1] local frameData = spriteTemplates[spriteType][2] local spriteSheet = graphics.newImageSheet(imageSheet, frameData) local sequenceData = spriteTemplates[spriteType][3] sprites[#sprites + 1] = display.newSprite(spriteSheet, sequenceData) local setup = { kind = "sprite", layer = mte.getSpriteLayer(1), locY = (regionY - 1) \* regionSize + x, locX = (regionX - 1) \* regionSize + y } mte.addSprite(sprites[#sprites], setup) end end end end end --...the rest of the enterFrame event... end
https://www.youtube.com/watch?v=YPiD5bqCouk