Game Mechanics Using invisible objects as solid platforms

M

my5t3r10n

Guest
Hello,

First time poster!

Anyways... I am here to ask a basic question on using a technique found in other game engines.

What I am doing is making a platform game where there are many types of ground to walk on and instead of adding all of those objects in my code I have made an object with low opacity for making the skeleton of the game. Then placing objects with ground sprites on top of them. When I start the game, the skeleton platforms disappear leaving the other sprites visible while honestly doing nothing. This is currently working for me btw.

If you're understanding what I'm saying, does that seem like a good option or are there better ways?
 

Attachments

kraifpatrik

(edited)
GameMaker Dev.
If the ground objects don't have any code, just draw a sprite, you could use tiles instead of them, which are not as heavy on performance as objects.
 
D

DariusWolfe

Guest
If you're trying to get collision, you can set a generic object with the shape you want and a featureless sprite, then draw the specific sprite you want in it's place. The sprite set as the object sprite will determine collision, but when you set a Draw action, it will only draw the object sprite if you specifically tell it to; If instead you tell it to draw another sprite, it will do that, and never draw the object sprite.

Alternately, you can also set a collision mask.

Another alternative is to create a bunch of different objects to represent different types of ground, but don't add any code to them at all; Instead, create another object which has any required code, and set it as the parent of your other ground objects. When you need to detect collisions, detect collisions with the parent object, and it will treat all of the child objects as instances of the parent object, and each child object will run whatever code you put into the parent object. (unless you define anything in the child object; Then you'll explicitly need to tell the child object to run the parent object's code). This will allow you to create your levels/terrain with objects of varying appearances, but identical behaviors, and allow you to change the behaviors by modifying a single object.

Edit: Re-reading your post, my last paragraph is how I would do what you're trying to do.
 

Yal

šŸ§ *penguin noises*
GMC Elder
I personally advocate either having visible ground objects, or have invisible ground objects that create tiles that cover them automatically on room start (and you can of course combine both in the same level). Putting down tiles first and then placing invisible objects everywhere just makes designing a level take twice as long.
 
Top