Hi all.
I'm using DragonFireSDK to make an iPhone app, which means that I can't use any external libraries other than the SDK one. I am trying to get an integer variable for score to a function which will display text on the screen. However, that function takes a char* variable. Here is my code (I've marked the lines that I think matter to the error):

//===============================================
// Example.cpp
//===============================================

#include "DragonFireSDK.h"
#include <math.h>
#include <cstdio>

//===============================================
int BackgroundImage;
int BackgroundView;
int CircleImage;
int CircleView;
int ShieldImage;
int ShieldView;
int Blob1Image;
int Blob2Image;
int Blob3Image;
int BlobViews [10];
int LeftArrowImage;
int LeftArrowView;
int RightArrowImage;
int RightArrowView;

int TurnVelocity;
int Angle;
int vX;
int vY;

int Font;
int ScoreText;
int Score;       //<<<<THIS LINE
char Score2;     //<<<<THIS LINE


//===============================================

int TouchAngle(int id, int event, int x, int y)
{
	if (id==1&&event==1)
	{
		TurnVelocity=-2;
		Score-=1;
	}
	if (id==2&&event==1)
	{
		TurnVelocity=-2;
		Score-=1;
	}
	if (event==3){TurnVelocity=0;}
	return 0;
}

int Translate(int x, int y)
{
	return 0;
}

void AppMain()
{
	LandscapeMode();
	Font = FontAdd("Arial12Bold");
	BackgroundImage = ImageAdd("background.png");
	BackgroundView = ViewAdd(BackgroundImage, 0, 0);
	CircleImage = ImageAdd("circle.png");
	CircleView = ViewAdd(CircleImage, 237, 157);
	ShieldImage = ImageAdd("shield.png");
	ShieldView = ViewAdd(ShieldImage, 200, 150);
	LeftArrowImage = ImageAdd("arrow_left.png");
	LeftArrowView = ViewAdd(LeftArrowImage, 20, 140);
	TouchAdd(0, 60, 50, 320, TouchAngle, 1);
	RightArrowImage = ImageAdd("arrow_right.png");
	RightArrowView = ViewAdd(RightArrowImage, 435, 140);
	TouchAdd(430, 60, 50, 320, TouchAngle, 2);
	ScoreText = TextAdd(8, 8, "Score: 0", Font);

	Score = 0;    //<<<THIS LINE
	Angle = 270;
}

//===============================================
void OnTimer()
{
	Score2 = Score;  //<<<THIS LINE
	TextSetText(ScoreText, Score2);   //<<<THIS LINE
	Angle+=TurnVelocity;
}

//===============================================

I get the error: error C2664: 'TextSetText' : cannot convert parameter 2 from 'char' to 'char *' Can somebody help me fix this?
Thanks,
Mark :)

See the example program at this link, and while you are there you might want to bookmark that link so that you can use it for future reference.

Edited 4 Years Ago by Ancient Dragon: n/a

OK I have replaced line 84 with

Score2 = char(Score);

but I get the error: "cannot convert from char to char [20]"

And I can't use sprintf anyway because that needs <cstdio>, which I can't use. Just realised I put that in the original code when I was trying something else earlier, sorry about that.

Building for iOS, so not sure if it's compatible with the final build program.

You need to find out what compiler you will be using and whether it is ansi C compliant. If it is, then it will support all the functions in stdio.h. If not then you may have limited options and have to convert from int to char* yourself (e.g. write your own simple version of sprintf without all the bells and whistles that the standard C version has).

Edited 4 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.