Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - zacho

Pages: [1] 2 3 ... 6
1
It could be acting choppy because you are calling the bitmap function in a touch event.
Might I suggest making two variables, one for x and y and remembering these in the on touch event but drawing them outside that function call? Give that a go

2
Game Programming / Re: Saving in-game data
« on: February 28, 2013, 10:59:28 pm »
The easiest would be to write to a file using the file commands in this order: (I have built functions around the dragonfiresdk functions but this is what I call):

File create.
Get file handle
Set cursor (not all the time, it's not necessary for my app)
Write to file


3
How Do I...? / Re: Social sharing
« on: February 28, 2013, 04:12:57 pm »
Yep!

4
How Do I...? / Re: How to record your own sound?
« on: February 28, 2013, 04:12:03 pm »
Well if you would like to record from the device, that currently isn't supported so shoot support an email if there is an undocumented implementation you can use otherwise wait for another update

5
Game Programming / Re: Recording a score out of documents folder
« on: February 27, 2013, 11:02:41 pm »
Ciuffolo, I made some functions for file reading and writing in the How To section of these forums if you want to use them. If you have questions about them I'd be glad and answer but if you found a solution that's good too!

6
Amazing! Thanks I will use this to make my UI!

7
How Do I...? / Re: How to record your own sound?
« on: February 27, 2013, 10:50:01 pm »
If you make a custom sound, try putting it in the right folder (I think it's assets) and give it a try. I don't know if it will work but if it does then that's good too!

8
How Do I...? / Re: iOS selector
« on: February 27, 2013, 10:46:45 pm »
This would be a hurdle to do but I'm sure its possible somehow. It might be too much trouble than its worth to try to implement this however.

9
How Do I...? / Re: Social sharing
« on: February 27, 2013, 10:44:42 pm »
There is nothing official but what my google search tells me you might want to look here to start, it seems this guy has done some API for facebook using c++ so it's a good foot in the door

http://code.google.com/p/facebook-cpp-graph-api/

10
How Do I...? / Re: Scrollers and Buttons
« on: February 26, 2013, 09:25:31 pm »
edit: nevermind. I figured it out ::)

11
How Do I...? / Re: How can i know if is there internet connection?
« on: February 26, 2013, 06:37:48 pm »
Sorry, you should use the timergetmsExpired and set a timeout for approx 20 seconds which would more or less state whether you have internet or not after a time period of elapse and then if true call the netsend with 127.0.0.1 to kill the previous netsend

Would you mind, if you have, and share the code that you use for this purpose?

12
How Do I...? / Re: How do I convert int to char or string?
« on: February 26, 2013, 06:36:21 pm »
Not a problem!

13
EASIER FILE FUNCTIONS::






I made a bunch of file functions, these need to be tested if they work on the device, but here they are:

Returns a handle to the file created (in Debug/Documents)

Just pass in a string of the file and it will create it, ie. "textfile.txt"
Code: [Select]
int createNewFile(std::string fileurl)
{
int temp = FileCreate(toCString(fileurl));

return FileOpen(toCString(fileurl));;
}

Returns file handle for object (is an integer)

ie. int filehandle = getFileHandle("file.txt");
Code: [Select]
int getFileHandle(std::string fileurl)
{
return FileOpen(toCString(fileurl));
}

Reads file contents into a string
-File handle needs to be passed in; ie the variable holding the file
-numOfBytes = number of bytes to be read in, ie. one char is one byte
-startByte = the byte you would like to start reading at, these are indexed (ie, it goes from 0 to length of file)

ie, string s = readFromFile(filehandle,10,0); //Will read the first 10 bytes into string 's'
There is protection in here, if you try to read past file it won't read anything
Code: [Select]
std::string readFromFile(int filehandle, int numOfBytes, int startByte)
{
char* buffer = new char[numOfBytes+1];
int fileLength = FileLength(filehandle);

if( (startByte + numOfBytes) <= fileLength ) //If we try to read out of bounds
{
FileSeek(fileHandle,startByte); //Set 'cursor' for reading bytes

FileRead(fileHandle,buffer,numOfBytes);

buffer[numOfBytes] = '\0'; //Null terminate the character arra
std::string s(buffer);

delete[] buffer;
buffer = 0;

return s;
}
else
{
delete[] buffer;
buffer = 0;

return "";
}

}

Writes a string to a file
Filehandle is needed to be passed in
text - string to write to file

This doesn't write to user-defined bytes in the file, but can be easily changed to do so.

example: writeToFile(filehandle,"I want to write this to the file");
Code: [Select]
void writeToFile(int filehandle, std::string text)
{
char* buffer = new char[text.length()];
for(int i = 0; i < (int)text.length(); i++)
*(buffer+i) = text[i];

FileWrite(filehandle, buffer, (int)text.length());

delete [] buffer;
buffer = 0;

return;
}

Opens file, returns true if file did exist previously

I think this is a useful function

example: if( openFile("file.txt") )
       //do something
Code: [Select]
bool openFile(std::string fileurl)
{
int temp = FileOpen(toCString(fileurl));

return temp != 0 ? true : false; //returns true if temp is not 0
//meaning a file did exist
}

Closes file handle

Can't forget this one
Code: [Select]
void closeFile(int filehandle)
{
FileClose(filehandle);
return;
}






Can't forget the helper functions that makes this easier too, at least for me because I don't like using char* for file things... :P

Pass in a string, get a char*

example: AlertShow(toCString("text"),toCString("more text") );

Code: [Select]
char* toCString(std::string s)
{
char* temp = new char[s.length()];

for(int i = 0; i < (int)s.size(); i++)
temp[i] = s[i];

temp[s.length()] = '\0';

return temp;
}

14
How Do I...? / Re: read/write to file
« on: February 25, 2013, 09:36:15 pm »
I made a bunch of file functions, these need to be tested if they work on the device, but here they are:

Returns a handle to the file created (in Debug/Documents)

Just pass in a string of the file and it will create it, ie. "textfile.txt"
Code: [Select]
int createNewFile(std::string fileurl)
{
int temp = FileCreate(toCString(fileurl));

return FileOpen(toCString(fileurl));;
}

Returns file handle for object (is an integer)

ie. int filehandle = getFileHandle("file.txt");
Code: [Select]
int getFileHandle(std::string fileurl)
{
return FileOpen(toCString(fileurl));
}

Reads file contents into a string
-File handle needs to be passed in; ie the variable holding the file
-numOfBytes = number of bytes to be read in, ie. one char is one byte
-startByte = the byte you would like to start reading at, these are indexed (ie, it goes from 0 to length of file)

ie, string s = readFromFile(filehandle,10,0); //Will read the first 10 bytes into string 's'
There is protection in here, if you try to read past file it won't read anything
Code: [Select]
std::string readFromFile(int filehandle, int numOfBytes, int startByte)
{
char* buffer = new char[numOfBytes+1];
int fileLength = FileLength(filehandle);

if( (startByte + numOfBytes) <= fileLength ) //If we try to read out of bounds
{
FileSeek(fileHandle,startByte); //Set 'cursor' for reading bytes

FileRead(fileHandle,buffer,numOfBytes);

buffer[numOfBytes] = '\0'; //Null terminate the character arra
std::string s(buffer);

delete[] buffer;
buffer = 0;

return s;
}
else
{
delete[] buffer;
buffer = 0;

return "";
}

}

Writes a string to a file
Filehandle is needed to be passed in
text - string to write to file

This doesn't write to user-defined bytes in the file, but can be easily changed to do so.

example: writeToFile(filehandle,"I want to write this to the file");
Code: [Select]
void writeToFile(int filehandle, std::string text)
{
char* buffer = new char[text.length()];
for(int i = 0; i < (int)text.length(); i++)
*(buffer+i) = text[i];

FileWrite(filehandle, buffer, (int)text.length());

delete [] buffer;
buffer = 0;

return;
}

Opens file, returns true if file did exist previously

I think this is a useful function

example: if( openFile("file.txt") )
       //do something
Code: [Select]
bool openFile(std::string fileurl)
{
int temp = FileOpen(toCString(fileurl));

return temp != 0 ? true : false; //returns true if temp is not 0
//meaning a file did exist
}

Closes file handle

Can't forget this one
Code: [Select]
void closeFile(int filehandle)
{
FileClose(filehandle);
return;
}






Can't forget the helper functions that makes this easier too, at least for me because I don't like using char* for file things... :P

Pass in a string, get a char*

example: AlertShow(toCString("text"),toCString("more text") );

Code: [Select]
char* toCString(std::string s)
{
char* temp = new char[s.length()];

for(int i = 0; i < (int)s.size(); i++)
temp[i] = s[i];

temp[s.length()] = '\0';

return temp;
}

15
How Do I...? / Re: How do I convert int to char or string?
« on: February 25, 2013, 09:19:48 pm »
To go from integer to string...

need to
Code: [Select]
#include <sstream>
up top



Code: [Select]
std::string toString(int i)
{
//Documentation for this is found at:
//http://www.cplusplus.com/articles/D9j2Nwbp/#boost

std::ostringstream convert; //This is a 'ostringstream' type

convert << i;

return convert.str();
}


And from integer to character (I am pretty sure this works, just not tested)..

Code: [Select]
char toChar(int i)
{
       return i - '0';
}

Pages: [1] 2 3 ... 6