Jump to content

Newbie C# question


Calimaw
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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();

Link to comment
Share on other sites

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.

 

:)

52t__nvidia.png nVidia 530M cpu.gif Intel Core i7 - 2.3Ghz 114229_30245_16_hardware_memory_ram_icon.png 8GB DDR3 RAM Windows7_Start.gif Windows 7 Ultimate (64x)

-----

IconVisualStudio16.png Visual Studio 2010 Ultimate google-Chrome.png Google Chrome PhotoshopLinkIndicator.png Creative Suite 5 icon28.gif FL Studio 10 MicrosoftOfficeLive.png Office 15

-----

csharp.png Expert cpp.png Professional lua_icon.png Expert BMX Programmer

-----

i-windows-live-messenger-2009.pngskype-icon16.pngaim_online.pnggmail.pngicon_48x48_prism-facebook.pngtunein-web.pngyahoo.giftwitter16.png

Link to comment
Share on other sites

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");

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Link to comment
Share on other sites

  • 2 months later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...