Register |
  (Advanced search)
Pages: [1]
Topic: SMBX 2.0 Editor Tutorials & Discussion  (Read 273 times)
Permalink  •  June 09, 2017, 02:32:06 AM
SMBX 2.0 Editor Tutorials & Discussion
« on: June 09, 2017, 02:32:06 AM »

As promised in the Super POS World 2 thread, I'll be creating several tutorials on using SMBX 2.0. There'll be some focus on comparing and contrasting it with Mario Maker, since most of us are very used to that.

Tutorial Index
Editor Basics
Sections and Warps
Tricky Terrain - Water, Quicksand, and Lava
Alternate Characters
Custom Music and Backgrounds
Layers and Events

Here's a bullet-point comparison of what differs between the two engines:
Spoiler for Hidden:
I'll just start with the "bad news" list. Stuff that's in Mario Maker and not SMBX 2.0b3:
-Flame Jets
-One-way blocks
-Conveyor belts exist, but only move at one slow speed.
-Rails exist, but only carry one type of platform, or grinders
-Only one checkpoint per level
-Making enemies bigger, giving enemies wings (bigger or winged versions of a few basic enemies exist)
-Enemies: Floor Ghosts, Monty Mole, Homing Bullet Bill
-Power-ups: cape feather, propeller mushroom
-The Clown Car is there but it's... weird.
Some of the items above can be worked around if you are inclined toward Lua scripting. In particular there is an API for multiple checkpoints that I have yet to try out. Also, some of these are planned for beta 4 "near the end of summer".

Now the fun part, Stuff that's not in Mario Maker and is in SMBX 2.0b3:
-Unlimited* level size (both x and y dimensions)
-Unlimited sub-levels
-Unlimited pipe & door warps
-Wrapping levels
-SMB1 one-way scrolling
-Custom tileset & background graphics
-Custom music
-Slopes
-Water tiles
-SMW style world map
-Multiple exits per level
-Event triggers! Create triggers like "Collect all red coins" or "stomp all goombas" to do things like "spawn a key" or "change the music", etc, etc.
-Moving blocks - make any level geometry move around!
-SMW-style "Reserve item"
-SMB2 mechanics: Digging up grass and sand, throwable enemies (shy guys etc).
-Colored Yoshis with SMW-like powerups
-Multiple playable characters: Mario, Luigi, Peach, Toad - and many more, each with unique gameplay twists!
-Power-ups: hammer suit, tanooki suit, ice flower, stopwatch
-Blocks: Switchable, Message, Diggable Sand, TNT, and more
-Enemies: Too many to list... notably most of SMB2, and some stragglers from SMW.
*Technically there are limits on these, but they're impractically large.
« Last Edit: June 11, 2017, 01:37:59 PM by Mia Kris »
Permalink  •  June 09, 2017, 02:44:46 AM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #1 on: June 09, 2017, 02:44:46 AM »

Tutorial: Editor Basics
-Once you've downloaded and extracted the SMBX2-Beta3 archive, open SMBX2.exe. This launcher gives the choice of a few built-in "episodes" (games) that you can play, but to get to the editor, use the "Launch Editor" button in the bottom-right.
-Once the editor loads up, go to File -> New -> Level...
-It's good to save your new level right away. Enter a title, and check the "Make custom folder" checkbox. This will create a folder alongside your level in which you can place custom assets or scripts. There's not much reason not to use it.
-Select the save location for your level and its custom folder to go in.
   I suggest creating a "World" folder at \SMBX2-Beta3\Data\Worlds\[your world folder] to put all your levels in. If you have a collection of levels plus a .wld world map file in that location, it'll be put in the Episodes dropdown in the launcher.

-Your new level will just be a black canvas, like this:
 
-First thing I recommend doing is picking a background. This is in the "Section Settings" window, pictured bottom-right.
   If you don't see that, or any other window I reference from here on out, go to the "View" menu on the top to turn it on!
-Also in the Section Settings menu, you can pick the music that will play in this section of the level.
   It's fairly easy to import custom background images and music; I'll cover this later.

-On the left side of the screen is the Level Item Toolbox, which is split into three broad categories of "Blocks" (level geometry), "BGO" (mostly noninteractive cosmetics), and "NPCs" (includes enemies, but also stuff like coins and power-ups). Each of these tabs can be filtered by "Group" (which Mario game) and/or "Category" (level theme or function).
-Let's first place some tiles. Under the Blocks tab, select a Group like "Grass and Ground", select a tile, and click and drag on the canvas to place it. Great, ya made some level geometry!


-Before we make the level any more complex, let's specify the player's starting position. There's a button in the top menus that looks like Mario's face:

This will allow you to place a marker that indicates the starting point.
   Unlike Mario Maker, this isn't just for testing - no matter where you put it, that's really where the level starts!
-As a starting position and some sort of geometry are the bare minimum for gameplay, let's do a test. In the menus you can select Test -> LunaTester -> Run Testing, or, simply press F5. After a brief load, you'll be playing your level!
 
   The basic controls are: Arrow keys to move, Z to jump, X to run, and ESC to pause. If you have a gamepad you may need to configure it from the Options menu in one of the premade episodes. I highly recommend a gamepad.

-Once you're done testing, you can select "Quit" from the pause menu, or simply close the game window.
   You can make changes and test again without even needing to save the level. This is great for iterative design!

-Let's add more geometry. For "Category", select "Sizeable blocks". These are similar to Mario Maker's "semi-solid platform", and can be dragged out as any size. 


-Next let's add an enemy. Under the NPC tab select the Enemy category. There are a lot here, and pretty much have the behavior/AI you'd expect. For example, if you put a Red Koopa Troopa on your platform, it won't walk off.

 
-Now we'll add a power-up. Create a ? block from the "? Blocks and bricks" category. Right-click it and go to "Properties..."
-Click on the button under "Block contents". By default the content is 1 coin, but you can instead select any NPC (any of 'em!). For now, just make it a mushroom or fire flower.
   You can specify contents in any type of block, though many blocks cannot normally be destroyed.

-Almost done. Let's make the level bigger (they always start at the size of one screen). In the Section Settings window, click the "Resize section" button. You can now simply click and drag any of the edges of the level to expand it in that direction.
   Unlike Mario Maker, there's practically no limit on how wide or tall your level can be - go wild!
   Also: blocks, NPCs, etc can all be placed outside the section boundaries. It's just a limit on where the player and camera can go during gameplay.


-Lastly, let's create an ending for the level. Filter the NPC tab to the "Exit Point" category. This gives you a few options of objects that end the level when the player touches them.

   The simplest are "Crystal Ball", "Magic Ball", or "SMB3 Card Roulette". Goal Tape requires appropriate BGOs to look right - try this out!

That's about it for the basic editor functions! Play around with more types of blocks and NPCs, and don't forget to save your level when you're done.
« Last Edit: June 09, 2017, 02:55:03 AM by Mia Kris »
Permalink  •  June 09, 2017, 03:13:37 AM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #2 on: June 09, 2017, 03:13:37 AM »

Tutorial: Sections and Warps
-Like Mario Maker, your level can have multiple sections - but now you can have as many as you want!
   Please don't make anything too complicated...

-Use this bar near the top to select a section:
 
-Once you open Section 2, you'll see that it's blank, just like when you first started your level. For each section, you'll need to select a background and music again.

-To travel between sections, we'll need to create Warps. Open the "Warps and Doors" window, if it's not open already. Within this menu, click the plus sign near the top right to create a new warp.
-For "warp type", let's select Pipe.
   Unlike Mario Maker, any type of warp can be used to travel either between or within sections.
-If you haven't already, place appropriate blocks from the Pipe category into both sections of your level.
   Technically you can put any type of warp anywhere, but it's good to be consistent with established conventions - usually...
-Click on "Set Entrance" and place it at the top-middle of your pipe, as shown here:

 
-Now do the same with "Set Exit" at the other end of your pipe.
-For "Pipe Direction", make sure to set the entrance to go Down.
-But we're not done yet! Each Warp is only one-way, so if we want to make a two-way pipe, we'll have to create a second warp. Do so, with the Entrance and Exit positions reversed.
   This may seem like a tedious extra step, but, it allows you to get creative with stuff like pipes that don't send you back to where you came from.



-Now let's try making a locked door. Place two door BGOs in your level.
   For some of these door options, the game is smart enough to animate the BGO when the player warps.
-Create two warps, with both having an entrance and an exit on each door.
-Enable the "Locked" checkbox on one of the doors. Awkwardly this setup doesn't allow you to have both warps unlock when you use a key, like in Mario Maker - doing that would require advanced scripting. I think for the vast majority of level designs, though, it's sufficient to just have one side of the pair locked.
   There's a "Door Lock" BGO in the _system category, but don't worry about placing it - it's automatically spawned when a locked warp and a door BGO line up.
-Create a "Key" NPC from the "Carryble tool" category. This can be placed on the ground, or specified as the contents of a block.
   Later when I cover Events, I'll show how to spawn a key upon killing enemies or collecting macguffins, like in Mario Maker.
-Now if you test your level, you'll find that you have to be holding the key to use the door. Once a key is used on a door, the key goes away and the door is permanently unlocked.


-If you use the "Level door: Exit only" option (which works with pipes too), using that warp counts as finishing the level. Feel free to use this!
   You may also notice a "Keyhole" BGO - touching this with a key also constitutes a level exit!
« Last Edit: June 09, 2017, 03:15:31 AM by Mia Kris »
Permalink  •  June 09, 2017, 01:48:30 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #3 on: June 09, 2017, 01:48:30 PM »

Tutorial: Tricky Terrain - Water, Quicksand, and Lava

-In the Section Settings window for a given section, there's an "underwater" checkbox. This makes the entire section take place underwater, just like Mario Maker's underwater levels.
-However, SMBX lets us place arbitrarily-sized bodies of water in our levels, too! I'll demonstrate.


-Ah, it looks like we're at the beach today! But, what's the beach without water? Let's place some!


-However, just placing water BGO tiles isn't enough - they're technically just cosmetic. To make this swimmable, there's another way to designate the area as containing water.


-Just click the Water icon (located near the start point icon), then click and drag a rectangle anywhere to place water. The specified area will now have water physics!
    If you have snap-to-grid on, Water can snap to half-tile intervals, which is what looks best with most water BGOs.
     With the Select tool, you can move, copy, or delete an existing water area.



     Be careful, going off the bottom of the screen still results in death!

-Right next to the Water button is a Quicksand button. Placing Quicksand works just like placing Water. Combine this with the "Quicksand Foreground" BGO tiles to create a not-immediately-lethal hazard.


-On the other hand, Lava is considered a block rather than BGO, and is automatically deadly to the player, so simply placing anything from the "Lava Blocks" category is all you need to do.

     The "Lava4" blocks have the most options for creating "shapes" with lava. Note the interaction with the Skull Raft NPCs.

That's all on these types of terrain.

Spoiler for Ah, well, one more thing...:
Once we learn about layers and a bit of scripting, we'll be able to do stuff like this:

Permalink  •  June 09, 2017, 06:41:19 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #4 on: June 09, 2017, 06:41:19 PM »

Tutorial: Alternate Characters

-Possibly the biggest added feature in SMBX compared to Mario Maker is the option of using different playable characters with unique mechanics.
-The original SMBX had five characters: Mario, Luigi, Peach, Toad, and Link. SMBX2 has expanded the roster to eighteen!
-This will be part tutorial, part showcase. The best way to learn about the alternate characters is to try them out yourself!

-As for how to change the player into another character, there are two ways that I know of.
-The first way is to place a block known as a character switch. These can be found in the "Player Block" category. They work like so:


-If you want the player to start your level as a specific character, that's done via Lua script. Again, we'll cover that in more detail later, but for now know that you'd want to have a file called lunadll.lua in your level's custom folder with the following code:
Code: [Select]
function onStart()
player.character = 1  --Put the desired character's ID here.
end

Spoiler for List of character IDs:
1: Mario
2: Luigi
3: Peach
4: Toad
5: Link
6: Mega Man
7: Wario
8: Bowser
9: Klonoa
10: Ninja Bomberman
11: Rosalina
12: Snake
13: Zelda
14: Ultimate Rinka
15: Princess Rinka
16: Uncle Broadsword
17: Juni
18: Samus

-So, on to some overviews of the characters! I'll be spoilering these out because it's a lot of .gif spam.

Spoiler for Luigi:
Luigi is actually the only character who doesn't have special mechanics like you'd expect! As far as I can tell he is just a reskin of Mario.
Spoiler for Peach:
Peach has her hover ability from SMB2.
Spoiler for Toad:
Like in SMB2, Toad runs faster than Mario but can't jump as high.
Spoiler for Link:
Link is based off his appearance in Zelda II. His sword can take out enemies and breakable blocks.
Spoiler for Mega Man:
One of the most impressive bits of programming here, Mega Man has a number of abilities depending on which power-up he gets... and can switch between them on the fly!
Spoiler for Wario:
Wario has two special abilities. If he runs for a while, his charge will break through blocks. Also, he can open up a shop interface at any time to exchange coins for power-ups.
Spoiler for Bowser:
Bowser can recruit enemies to follow him and fight at his command.
Spoiler for Klonoa:
I've never played this game before, but it looks like Klonoa can grab&toss enemies, and also float for a bit.
Spoiler for Ninja Bomberman:
This one seems quite powerful. He can double-jump, drop bombs, and hover.
Spoiler for Rosalina:
It's her...! She can double-jump (though her base jump is much shorter), and hover. Collecting coins fills a meter that can be consumed to gain a starman power-up.
Spoiler for Solid Snake:
This one's quite funny. Enemies will gain flashlights, and if Snake is spotted, additional enemies will spawn for a while. Be careful...!
Spoiler for Zelda:
Zelda can teleport vertically if standing on the ground. Her Ocarina can "save and restore" the status of breakable blocks.
Spoiler for Uncle Broadsword:
I don't even know what game this guy's from! But, his sword attacks are very agile, and can even suspend him in the air for a bit.
Spoiler for Juni:
This mysterious girl isn't very capable at first, but gains numerous abilities when collecting power-ups.
Spoiler for Samus:
Samus gains new weapons as power-ups are collected. The morph ball's here, too.

-Another fancy block we can look at is the Costume Block. Each character has multiple costumes that change their sprites - this is cosmetic only.

     Some of these are pretty clearly developer injokes, but, for instance, we might want to use SMW Mario primarily.

-If you looked at the character switches, you probably also saw the character blocks. These are blocks that become passable only when playing as that character. I wonder what kind of puzzles you could make with these?
« Last Edit: June 11, 2017, 11:51:13 AM by Mia Kris »
Permalink  •  June 10, 2017, 02:37:34 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #5 on: June 10, 2017, 02:37:34 PM »

If you're working through these, feel free to post your own screenshots and/or questions!
Permalink  •  June 10, 2017, 02:58:04 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #6 on: June 10, 2017, 02:58:04 PM »

Uncle Broadsword is literately a original character do not steal from a game the developers are working on. So more of that shit.

Zelda changes her song with certain pickups (and doesn't change back when she loses them); fire flower changes it to saving and restoring her position, and another one saves and restores enemies.

Quote from: Lolicon Jon
i got anime of all tastes and sizes
come down to jon's anime emporium where we can satisfy your anime needs
1000 episode shounens, WE GOT IT
men(or little boys) kissing and loving each other, WE GOT IT
Nosebleeds from seeing the tiniest bit of skin of a woman, WE GOT IT
so come on down to jon's anime emporium down on the highway
like right on the highway
Permalink  •  June 10, 2017, 06:06:51 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #7 on: June 10, 2017, 06:06:51 PM »

Tutorial: Custom Music and Backgrounds

-This is where the "Custom Folder" for your level is going to come into play!
-Again, the folder structure is to have a folder with the name of your level in the same directory as the .lvl file itself, like so:


-To add custom music, just place one or more songs into the custom folder.
     A wide variety of formats are supported!
-Once you have your song(s) in the folder, go to the Section Settings window in the editor, select "Custom" for music, and click the browse button under "Music file:". You should see a list of all the songs you put in your custom folder. Just pick one, and... that's all there is to it!

     If you have multiple custom songs, you can pick a different one for each section of the level.

-Backgrounds are slightly more complex to set up. The basic idea is that we're going to replace one of the built-in backgrounds.
-There are a couple format requirements. Backgrounds have to be in .gif format. The image must be at least 600 pixels tall (the height of one screen). Width doesn't matter, as backgrounds are always tiled horizontally.

-As an example, let's say I want to use this background from Kirby Super Star:

-Looks pretty nice, but it's only 168 pixels high. I'll do a 400% nearest-neighbor resize on it so that it meets the 600px height requirement.
-Next, I'll place the resized .gif in my level's custom folder. Unlike music, this needs a specific filename format: "background2-53.gif" without the quotes.
-What this is doing is telling the editor to replace built-in background #53 with our custom background. It doesn't have to be #53 specifically, but due to the way background configs are set up, you have to be careful not to replace one of the animated backgrounds or you'll get something like this:
Spoiler for Replacing an animated background:
     Other good options for backgrounds without fancy configs are #20 or #48.
-Once you have the background in place with the proper filename, you'll see it show up in that spot in the background image options. There will be an asterisk in front of the name to indicate that it's a custom graphic.


-A somewhat technical side note: if the height of the section is taller than the background image, the game will employ vertical parallax scrolling. This will be done such that in-game, the bottom of the section will line up with the bottom of the image and the top of the section will line up with the top of the image. A bigger gap between the section size and the image size will result in the background appearing "farther away" from the foreground.
« Last Edit: June 10, 2017, 06:12:44 PM by Mia Kris »
Permalink  •  June 10, 2017, 07:57:15 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #8 on: June 10, 2017, 07:57:15 PM »

Tutorial: Layers and Events

-My favorite post-launch addition to Mario Maker was the pink coins that would spawn a key when they were all collected. Good news, we can do this - and quite a bit more! - with the Layers and Events systems.
-I made a video a while ago to show this off.
Click to load


-First, we'll do "Collect all the red coins to spawn a key".
-Make sure you have both the Layers and Events windows open.

-Click "Add" in the Layers window, and name your new layer "Red Coins" (the layer name can be anything, but it's good to be descriptive).
-In the Classic Events window, click the plus sign to add a new event. Name it something like "Red Coins Collected".

-Next, place some Red Coins in your level. Select them, and use the right-click menu to change which Layer they're assigned to.

     Blocks, BGOs, and NPCs can all be assigned to layers. You can use layers to put multiple blocks or NPCs in the same tile, though the graphics can render strangely depending on how this is done.

-Still having all your Red Coins selected, right-click and go to Properties.
-The four drop-downs at the bottom of this window allow you to configure the coins as an Event trigger.
-In this case we want to set "Layer is empty" to trigger the custom event we created.


-Next, we'll need a Key that's in a separate layer. Place a Key in your level, and from the right-click menu select "Add to new Layer..."
-Check the box for "Hidden", since we don't want the key to be visible to the player initially.


-You'll actually see the key disappear in the editor, but if you need to see it again, you can toggle the layer visibility with the checkbox in the Layers window.


-Now that both layers are configured, select your Red Coins Collected event in the Events window. Under "Layer Visibility", add Key to the Show field. Like this:


-That's all you need to do for a functioning, SMM-like "Collect the red coins to spawn a key" mechanic!


-You may have noticed one of the triggers was "On Death". This can be used to spawn stuff when enemies die.

     The "on death" trigger doesn't require the enemy to be in particular layer. However, if you want to do something like "spawn the key after killing a set of Goombas", use "Layer is empty" on a layer full of Goombas instead.


-Another important event function is "Layer Movement". We can use this to set up simple moving platforms.
-As an example, let's make this cloud move left and right over a gap.


-First, put the cloud in its own layer.
-Now create two events, "cloud move right" and "cloud move left".
-For "Cloud move right", check the "Autostart event" box - this will cause the event to start immediately when the game loads.
-Open "Layer movement", select the Cloud layer, and set Horizontal speed to 1 (block per second).
-Then, open "Trigger Event", select the "cloud move left" event, and set a delay of 2.0 (seconds). Thus, 2 seconds after the "cloud move right" event starts, it will trigger the "cloud move left" event.


-Similarly, configure "cloud move left" to set horizontal movement to -1 (negative values mean left), and set it to trigger "cloud move right" with a 2 second delay.
-Now when you test the level, the cloud should be moving!


-There's not much limit to the scope of Layer Movement events. For instance, you can make fairly large hazards too!


That's all the basics on how to make Layers and Events work with each other. Figuring this stuff out was when I really felt sold on this engine being a more powerful creation tool than Mario Maker. So, be creative and explore the possibilities!
stake mistakes (dan deacon reference)
  • stake mistakes (dan deacon reference)
Permalink  •  June 11, 2017, 02:56:46 AM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #9 on: June 11, 2017, 02:56:46 AM »

 :yeah!:

Well, I can't promise that my first level will be first-place material... but from the experimenting I've done using your tutorials I'm pretty excited to make it!

Oh, I might have skipped over such a detail in my reading, but, is it possible to make custom characters, or custom character costumes? :o
Permalink  •  June 11, 2017, 03:38:25 AM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #10 on: June 11, 2017, 03:38:25 AM »

Well, I can't promise that my first level will be first-place material... but from the experimenting I've done using your tutorials I'm pretty excited to make it!
That's ok! Something we learned from our time with Mario Maker is that even levels without a bunch of fancy mechanics can still be fun.

Oh, I might have skipped over such a detail in my reading, but, is it possible to make custom characters, or custom character costumes? :o
It seems complicated. Custom characters seem to take significant amounts of coding. You can find the nuts 'n' bolts in \SMBX2-Beta3\data\LuaScriptsLib\Characters... Rosalina's on the simple side with ~400 lines of code, while the most complex, Mega Man, has ~1,000 lines.
Costumes (found at \SMBX2-Beta3\data\graphics\costumes) seem a little simpler... there's .ini files with each one, but I assume they're just hitbox data, and probably wouldn't need to be tweaked much.
The real question I would have on both characters and costumes, though, is whether they can be put into a level or episode's custom folder. If I were to create, say, "Dark Rosalina" by just dropping some recolored sprites in the location previously specified, I'd need you to overwrite the sprites in the same location on your end if you wanted to see the changes... this is why the system of loading elements from a level's custom folder is good, since it doesn't require the player who the level was shared with to replace any of SMBX2's built-in assets.
I will no doubt do more research on this, but I'll probably be tackling custom NPCs first, since those I know can be done per-level.
Permalink  •  June 11, 2017, 07:14:10 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #11 on: June 11, 2017, 07:14:10 PM »

LunaLua
Well, I won't necessarily do a lengthy tutorial on LunaLua... the community documentation is pretty thorough, and there are even some tutorials there that probably explain things better than I would.
Moreover, I think that we can already make a lot of very fun & interesting levels just using what I've shown so far. Going into this Lua stuff should be considered optional, for our purposes. The last thing I want is for this proposed Mario Maker alternative to feel overwhelmingly complicated!

If you do feel like writing some code, though, I'll give a few very basic details on what you need to know:

-In your level's custom folder, put a file called "lunadll.lua". This script will be loaded when your level starts, and functions in it will run in response to things that happen in the game.
-I recommend starting with a template that includes three common functions: onStart, onTick, and onEvent.
Code: [Select]
function onStart() --Stuff that happens after engine assets are loaded but before the player gets control.

end

function onTick() --This function will run once per frame, except when the game is paused.

end

function onEvent(eventname)  --This function will run every time the specified event happens.

end

-Pretty simple, right?
-Initialize variables (player state, layer movement, etc) in the onStart() function. Use while or if statements in onTick() to do things at regular intervals, or to check the game state. Use onEvent(eventname) to supplement the functionality of the in-editor Events.
-Keep these wiki pages handy: Global functions and Classes. Objects of most classes will require that a reference be built using the appropriate global function (though there are a few built-in references, like "player".)

-If you want to know more than that, really, take a look at the existing tutorials!
« Last Edit: June 11, 2017, 07:19:30 PM by Mia Kris »
Permalink  •  June 18, 2017, 08:52:26 PM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #12 on: June 18, 2017, 08:52:26 PM »

Here's a basic layer movement lua script like I've been using:

Code: [Select]
function onStart()
layer1 = Layer.get("layer1")
layer1.speedX = -1
t = 0
end

function onTick()
layer1move()
if (player:mem(0x124,FIELD_DFLOAT) == 0) then  --Checks if the player is in a forced animation state.
t = t+1
end
end

function layer1move()
if t % 240 == 0 then
layer1.speedX = layer1.speedX * -1
end
end

The end result of this code is that whatever is in "layer1" will move left and right at 1bps, alternating every four seconds (240 frames). This is very similar to what I showed in the events tutorial, but has two advantages. First, it's easier to adjust on the fly: if you decide you want the movement to reverse every two seconds, or to go at a speed of 2bps, it's just a matter of changing a couple numbers in your lua file. Second, it does allow for fancier types of animation. Consider:
Code: [Select]
layer1.speedY = math.sin(t/60)
Adding this will make the layer appear to "bob" up and down.

Also, note the line I've commented. I found that layer movement stops whenever the player is in a "forced animation" state (getting a power-up, going through a pipe, etc). This would cause something like picking up a Mushroom to throw off my layers' positions, since the frame counter would increment while movement wasn't happening. The if statement there checks for whether the player is in one of these forced animations, and only increments the frame counter if they're not.
« Last Edit: June 18, 2017, 08:55:32 PM by Mia Kris »
Permalink  •  June 19, 2017, 12:28:13 AM
Re: SMBX 2.0 Editor Tutorials & Discussion
« Reply #13 on: June 19, 2017, 12:28:13 AM »

Editing individual sprites is quite easy!
Right-click on any Block, BGO, or NPC in the Level Item Toolbox and select "Copy graphic to custom folder". The resulting graphic can be edited however you want (as long as the dimensions and filename stay the same), and since it's in your level folder the changes will immediately be applied just within your level.
As an example, there's a "Hurt Block" with a fairly generic graphic, which I changed to the Spike Block from Super Mario Maker (since the function is the same). Or, maybe you simply want to recolor some things to fit your level's theme. This is just one more way to allow for greater creativity!
Pages: [1]