View previous topic :: View next topic |
Author |
Message |
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: 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 |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: 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 |
|
|
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: Sat Feb 27, 2010 1:31 pm Post subject: |
|
Kods varetu teikt ir identisks majaslapa sastopamajam.
Mekleju, bet nesmu atradis. |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: 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 |
|
|
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: Sat Feb 27, 2010 1:43 pm Post subject: |
|
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
kkas lidzigs
DoCreate(device); ? |
|
Back to top |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: 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 |
|
|
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: Sat Feb 27, 2010 1:57 pm Post subject: |
|
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 |
|
|
Desis
Joined: 29 Jul 2008 Posts: 2
|
Posted: 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 |
|
|
martinezzz
Joined: 02 Feb 2010 Posts: 42
|
Posted: 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 |
|
|
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: 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 |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: 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 |
|
|
martinezzz
Joined: 02 Feb 2010 Posts: 42
|
Posted: 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 |
|
|
snwlv
Joined: 10 Jan 2010 Posts: 86
|
Posted: Mon Mar 01, 2010 4:06 pm Post subject: |
|
ne vel nav. |
|
Back to top |
|
|
martinezzz
Joined: 02 Feb 2010 Posts: 42
|
Posted: 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 |
|
|
bubu Indago Uzvarētājs
Joined: 23 Mar 2004 Posts: 3223 Location: Riga
|
Posted: Mon Mar 01, 2010 5:26 pm Post subject: |
|
C++'am ar XNA ir maz sakara. |
|
Back to top |
|
|
|