dev.gamez.lv Forum Index dev.gamez.lv
Latvian Game Developers Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 

Failu izveide un ielade
Goto page 1, 2  Next
 
dev.gamez.lv Forum Index -> Iesācējiem
View previous topic :: View next topic  
Author Message
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Sat Feb 27, 2010 1:17 pm    Post subject: Failu izveide un ielade

Sveiki.Gribu noskaidrot kādas komandas norāda failu saglabašanu,dzešanu,izveidošanu pēc šīs pamacibas.

http://msdn.microsoft.com/en-us/library/bb200105.aspx

Nepieciešamas butu 3 komandas,tada kuras norada precizu darbibu.
kā piemeram DoCreate(...);
Bilde
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Sat Feb 27, 2010 1:27 pm    Post subject:

Tur jābūt tam, ko tu gribi panākt. Neviens nezinot tavu kodu, tā uzbūvi vai tavas vajadzības spēlei neko tev pateikt nevarēs.
Back to top
View user's profile Send e-mail
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Sat Feb 27, 2010 1:31 pm    Post subject:

Kods varetu teikt ir identisks majaslapa sastopamajam.
Mekleju, bet nesmu atradis. Rolling Eyes
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Sat Feb 27, 2010 1:38 pm    Post subject:

Nesaprotu par ko tu runā. Ja jau kods ir identisks, tad kur ir problēma? Kas nestrādā? Paņem kodu un lieto, ja jau tas ir identisks.

Iepriekš domāju, ka tu prasi kā/ko rakstīt/lasīt tavos failos, kad tavai spēlei izvēlās New Game vai Load Game. Un to toč tu neatradīsi MSDN'ā. Tur tu atradīsi tikai kā to darīt (funkciju/metožu nosaukumus, argumentus utml). Bet kādus datus raksīt/lasīt - tas ir atkarīgs tikai no tavas spēles vai programmas, ko taisi.
Back to top
View user's profile Send e-mail
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Sat Feb 27, 2010 1:43 pm    Post subject:

Very Happy nu es jau prasu ka vinus izmantot
Piem:

Code:

private static void DoCreate(StorageDevice device)
{
    // Open a storage container.
    StorageContainer container =
        device.OpenContainer("StorageDemo");

    // Add the container path to our file name.
    string filename = Path.Combine(container.Path, "demobinary.sav");

    // Create a new file.
    if (!File.Exists(filename))
    {
        FileStream file = File.Create(filename);
        file.Close();
    }
    // Dispose the container, to commit the data.
    container.Dispose();
}

man vajadzetu komandu ar kuru vins izveidotu jaunu failu kad uzspiez
New Game
Rolling Eyes
kkas lidzigs
DoCreate(device); ?
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Sat Feb 27, 2010 1:47 pm    Post subject:

Tieši to jau tavs kods arī dara. Tajā kontainerī (fig zin kas XNA vidē tas ir) uztaisa failu demobinary.sav. Izpildi šo kodu, kad uzspiež New Game un uztaisīsies tavs fails.
Back to top
View user's profile Send e-mail
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Sat Feb 27, 2010 1:57 pm    Post subject:

Very Happy
sanak kad
Code:

if (DzivsJautajums)//tiek prasits vai velaties izveidot jaunu karjieru.
            {
                if (Klaviatura.IsKeyDown(Keys.N))//Ne
                    Jautajums1.J1 = false;

                if (Klaviatura.IsKeyDown(Keys.Y))//JA
                    Jautajums1.J1 = false;
                  //seit ievietot apaksa mineto kodu
            }

kods
Code:

  private static void DoCreate(StorageDevice device)
                     {
                    StorageContainer container =
                    device.OpenContainer("DreamLegionSave");

                     string filename = Path.Combine(container.Path, "DLbinary.sav");

                    if (!File.Exists(filename))
                    {
                    FileStream file = File.Create(filename);
                    file.Close();
                    }
                     container.Dispose();
                    }


ka vinju ievietot lai nav eroru?
Back to top
View user's profile
Desis



Joined: 29 Jul 2008
Posts: 2

PostPosted: Sun Feb 28, 2010 12:01 pm    Post subject:

Es ieteiktu saakt nevis ar speeles veidoshanu uzreiz, bet gan ar C++ vai taisni C# pamatu pamaaciishanos.

kaut vai sho izlasot ieskatam:

http://www.gamedev.lv/article/c_pamati

---------------------

bet atbildot uz tavu konkreeto jautaajumu:

http://msdn.microsoft.com/en-us/library/bb203920.aspx

piemeers kaa izsaukt tavu piemineeto funkciju:

Code:

public Game1()
{
    graphics = new GraphicsDeviceManager(this);
    Content.RootDirectory = "Content";

    this.Components.Add(new GamerServicesComponent(this));
}
IAsyncResult result;
Object stateobj;
bool GameSaveRequested = false;
GamePadState currentState;

protected override void Update(GameTime gameTime)
{
    GamePadState previousState = currentState;
    currentState = GamePad.GetState(PlayerIndex.One);
    // Allows the default game to exit on Xbox 360 and Windows
    if (currentState.Buttons.Back == ButtonState.Pressed)
        this.Exit();

    if ((currentState.Buttons.A == ButtonState.Pressed) &&
        (previousState.Buttons.A == ButtonState.Released))
    {
        // Set the request flag
        if ((!Guide.IsVisible) && (GameSaveRequested == false))
        {
            GameSaveRequested = true;
            result = Guide.BeginShowStorageDeviceSelector(PlayerIndex.One,
                null, null);
        }
    }
    // If a save is pending, save as soon as the
    // storage device is chosen
    if ((GameSaveRequested) && (result.IsCompleted))
    {
        StorageDevice device = Guide.EndShowStorageDeviceSelector(result);
        if (device != null && device.IsConnected)
        {
            DoSaveGame(device);
        }
        // Reset the request flag
        GameSaveRequested = false;
    }
    base.Update(gameTime);
}
Back to top
View user's profile
martinezzz



Joined: 02 Feb 2010
Posts: 42

PostPosted: Sun Feb 28, 2010 8:15 pm    Post subject:

if (DzivsJautajums)//tiek prasits vai velaties izveidot jaunu karjieru.
{
if (Klaviatura.IsKeyDown(Keys.N))//Ne
Jautajums1.J1 = false;

if (Klaviatura.IsKeyDown(Keys.Y))//JA
Jautajums1.J1 = false;
DoCreate(device) ;
}



laikam taa..
_________________
ART, CG , CAD , SOUND , DEV

http://martinezzz.info
Back to top
View user's profile Visit poster's website
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Sun Feb 28, 2010 9:13 pm    Post subject:

Jau iepriekš meiģināju
reultāts
Errors:
An unhandled exception of type 'System.NullReferenceException' occurred in
Back to top
View user's profile
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Sun Feb 28, 2010 10:12 pm    Post subject:

Tas nozīmē, ka objekts, kuru tu aiztiec, ir null. Debugeris tev pasaka pat priekšā kurā tieši rindiņā tas notiek. Atliek debugerī apskatīties uz mainīgo vērtībā un redzēt, kurš ir vainīgais.
Back to top
View user's profile Send e-mail
martinezzz



Joined: 02 Feb 2010
Posts: 42

PostPosted: Mon Mar 01, 2010 11:09 am    Post subject:

emm ta starpcitu gribeju pajautat vai pati spele jau ir uzrakstita ?
_________________
ART, CG , CAD , SOUND , DEV

http://martinezzz.info
Back to top
View user's profile Visit poster's website
snwlv



Joined: 10 Jan 2010
Posts: 86

PostPosted: Mon Mar 01, 2010 4:06 pm    Post subject:

ne vel nav.
Back to top
View user's profile
martinezzz



Joined: 02 Feb 2010
Posts: 42

PostPosted: Mon Mar 01, 2010 4:55 pm    Post subject:

amm tad jau vel nav istais laiks domat par saglabashanu !!!

uzraksti pashu speli sakuma !!



a taa paskaties sho

http://www.cplusplus.com/doc/tutorial/files/



tipa


// basic file operations
#include <iostream>
#include <fstream>
using namespace std;

int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
_________________
ART, CG , CAD , SOUND , DEV

http://martinezzz.info
Back to top
View user's profile Visit poster's website
bubu
Indago Uzvarētājs
Indago Uzvarētājs


Joined: 23 Mar 2004
Posts: 3223
Location: Riga

PostPosted: Mon Mar 01, 2010 5:26 pm    Post subject:

C++'am ar XNA ir maz sakara.
Back to top
View user's profile Send e-mail
Display posts from previous:   
dev.gamez.lv Forum Index -> Iesācējiem All times are GMT + 2 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group