Calimaw Posted May 3, 2010 Posted May 3, 2010 I created a class file called SceneBuilder.cs which is where I want to place some functions for auto-building my scene based on entities it discovers and their Key values. using Leadwerks; using System; namespace LWTest01 { public class SceneBuilder { public Entity child; public String colorString; public Color color; public void Atmosphere(Scene inScene) { child = inScene.GetChild("atmosphere_1"); colorString = child.GetKey("fogcolor"); color = new Color(new float[] { float.Parse(colorString.Split(',')[0]) / 255, float.Parse(colorString.Split(',')[1]) / 255, float.Parse(colorString.Split(',')[2]) / 255, float.Parse(colorString.Split(',')[3]) / 255 }); Framework.Effects.DistanceFog.Color = color; } } } The above is the entire class file, but when I try to call it in my main with SceneBuilder.Atmosphere(); it will only allow me to put in SceneBuilder, as if it's a type. I'm almost certain I did something wrong with defining the class, and it thinks its a type or something, can some one explain to me how I can consolidate a series of functions in another file to keep my main clean? Quote
Rick Posted May 3, 2010 Posted May 3, 2010 SceneBuilder is a type. The only way you can do SceneBuilder.Atmosphere() is if Atmosphere() is defined as static. Otherwise you have to make an object and call it via that way. SceneBuilder scene; scene.Atmosphere(); Quote
Calimaw Posted May 3, 2010 Author Posted May 3, 2010 Alright, got it. thanks Edit: I thought I might as this now, is every one else doing something similar for auto-building their scenes? Quote
Calimaw Posted May 3, 2010 Author Posted May 3, 2010 Any one please feel free to respond, I'm a big newb to C# and game programming, so any thoughts are helpful for me. I don't know the best way to do things so another perspective helps me make decisions Quote
TylerH Posted May 7, 2010 Posted May 7, 2010 Well, if by auto-building you mean setting up, I think anyone making large scale levels for games is using the Leadwerks Editor. There is no reason you can't setup a game entirely in code or the world as well, but there are advantages and disadvantages to both approaches. Quote nVidia 530M Intel Core i7 - 2.3Ghz 8GB DDR3 RAM Windows 7 Ultimate (64x)----- Visual Studio 2010 Ultimate Google Chrome Creative Suite 5 FL Studio 10 Office 15 ----- Expert Professional Expert BMX Programmer -----
ZioRed Posted May 7, 2010 Posted May 7, 2010 I'm planning a kind of scene builder which parses a SBX file and loads it "manually" in multi-threading mode so that it let me to define a callback (for each entity load) which I can use to show a more or less accurate progress bar. For the atmoshpere example: why you need to set it manually from the scene? Initializing the framework with lua enabled did not work? Graphics.Initialize(800, 600); Framework.Initialize(true); Scene.Load("abstract::terrain_artic.sbx"); Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com
Fester Posted July 15, 2010 Posted July 15, 2010 SceneBuilder myScene = new SceneBuilder(); myScene.Atmosphere(); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.