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 - Micboy

Pages: 1 2 [3] 4 5 6
31
How did you guys link up your app with GameCentre? Need lots of help?!

32
Game Programming / Re: Adding a picture
« on: July 21, 2013, 01:15:53 pm »
Hiya,

So make sure you call the image file:
unpressed left button -  left1,png
pressed left button - left2.png
unpressed right button - right1.png
pressed right button - right2.png

Then do button add
int SmallButt = ButtonAdd(container_handle, "Images/left" , x, y, OnButton, 0);
int BigButt = ButtonAdd(container_handle, "Images/right" ,x,y, OnButton, 1);

Thank you and I hope that I answered your question,
Micboy

Please would you be able to answer my question here?
http://dragonfiresdk.net/forum/index.php?topic=633.0

33
Game Programming / Re: Max number of containers?
« on: July 21, 2013, 01:11:07 pm »
Hiya,

I don't think there's a limit, but it just uses up memory so the program runs slower and slower until it eventually crashes.

For example, in my game, I have 6+ packs, with 40 levels each. By 6+ I mean that there may be more, but 6 is the minimum.

I think what you're saying is that in my case, I would initialise containers for each and everything single level, that would be a grand total of 240 levels (4*60) - 240 containers is a lot especially if you have a tonne of graphics in it. At first, I sort of did that, but that I decide to initialise one game container in which each level would be initialised into that. That saved me using 240 containers!

I think the best way for you would be to do the same.

Thank you and I hope that I answered your question,

Michael

Btw, would you be able to answer my question here? http://dragonfiresdk.net/forum/index.php?topic=633.0

34
Game Programming / Scrolling....again
« on: July 21, 2013, 01:05:46 pm »
Hi guys,

It's been a while since I last posted, but for you that's probably a good thing =P

I recently stalled when I couldnt identify the bug in the program.

So I'm using the scrolling code in http://dragonfiresdk.net/forum/index.php?topic=360.0 and I have introduced 2 scrolling surfaces in 2 different containers. One of then is a horizontal scrolling object and the other is a vertical scrolling object. However, the problems arises when the 2nd scrolling object doesnt flow - it moves as far as the finger does, even if I try to swipe it.

Am I missing something?

Thank you in advance!

Micboy

35
How Do I...? / Re: Scrollers and Buttons
« on: July 20, 2013, 12:49:46 pm »
Ever wanted to create scrolling menus in DragonFireSDK? Now you can.

I created two classes, one called Scroller and another called ScrollButton. Scroller creates scrollers with elasticity and friction. ScrollButton creates buttons for the scroller. If you don't move, you click the button. If you move, you don't click the button and drag the scroller.



Watch the video here:
http://www.youtube.com/watch?v=J1UELzjk0XE&feature=g-upl

Scroller.h
Code: [Select]
/* Copyright 2012 Juan José Sánchez Ramírez

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

   Author Juan José Sánchez Ramírez
   Co-author Nico91 at www.dragonfiresdk.net/forums
   Version 2.2.1
*/

#ifndef SCROLLER
#define SCROLLER

int nOldX;
int nOldY;
int nNewX;
int nNewY;

int nTouchId;
int nTouchEvent;

// This function will be called when a scroller is activated
int OnTouch(int id, int event, int x, int y)
{
// Get the ID of the container
nTouchId = id;

// Get the event of the container
nTouchEvent = event;

// Record initial coordinates when pressed down
if (event == 1)
{
nOldX = x;
nOldY = y;
nNewX = x;
nNewY = y;
}

// Record new coordinates when moving
if (event == 2)
{
nNewX = x;
nNewY = y;
}

// Erase coordinates when released
if (event == 3)
{
nOldX = 0;
nOldY = 0;
nNewX = 0;
nNewY = 0;
}

return id;
}

// This function approximates a container to it's target position.
void SlideContainer(int container, int targetX, int targetY, int speed)
{
/* To approximate the container, we're going to do the following:

   1. We get the container's x and y positions on the screen.
   2. If the value is less than the target value, we substract the
      value from the target value. If the value is more than the
  target value, we substract the target value from the value.
   3. We divide the difference by the speed.
   4. If the result equals 0, we make it equal to 1.
   5. If the value is less than the target value, we add the result
      to the value. If the value is more than the target value, we
  substract the result from the value.
   6. Finally, we set the container's position to our x and y values.
*/

int x = ContainerGetx(container);
int y = ContainerGety(container);

if (x < targetX)
{
int n = (targetX - x) / speed;
if (n == 0) n = 1;
x += n;
}
else if (x > targetX)
{
int n = (x - targetX) / speed;
if (n == 0) n = 1;
x -= n;
}

if (y < targetY)
{
int n = (targetY - y) / speed;
if (n == 0) n = 1;
y += n;
}
else if (y > targetY)
{
int n = (y - targetY) / speed;
if (n == 0) n = 1;
y -= n;
}

ContainerSetxy(container, x, y);
}

// This class creates a simple scroller for containers
class Scroller
{
/* A scroller lets a container slide upon a portion of the screen.
   It's designed to move containers that are too big for the screen,
   both vertically and horizontally, but it can be modified to move
   smaller objects too, such as sliders. This can be achieved by
   modifying minimum and maximum ranges, using the SetMinX, SetMinY,
   SetMaxX, and SetMaxY functions, or alternatively, using the
   SetBoundaries function, which modifies all of these values at once.

   The scroller uses the following components:

   1. A container which contains all of the elements in the scroller.
   2. A touch component which must be at least the size of the
      entire container, which records the drag and drop actions.
   3. An ID number that allows to differentiate among scrollers,
      since all scrollers use the same OnTouch function.
   
   The recoil component uses the following variables:

   1. Elasticity, defined here as the property of an object to return
      to its original state after a stress. In this particular context,
  elasticity can be thought of as how fast the container returns to
  its position.
 
  Note: The lower the value, the higher the elasticity!

   2. Compliance, defined here as the inverse of elasticity. In this
      particular context, compliance can be thought of as the resistance
  of a container to move out of position.

  Note: The higher the value, the higher the compliance!
   
   The friction component uses the following variables:

   1. Max Speed, defined here as the maximum sliding speed between two
      bodies, independent of the acceleration.

   2. Friction Coefficient, defined here as an empirical property of the
      containers which describes the force of friction between two bodies
  and the force pressing them together. For example, ice on steel has
  a low coefficient of friction, while rubber on pavement has a high
  coefficient of friction.

   3. Momentum, defined here as the property of containers to continue
      moving until stopped by a force of friction. The greater the
  momentum of a container, the stronger the force of friction that
  is required to stop the container.
*/

private:

int m_nContainer;
int m_nTouch;

int m_nX;
int m_nY;

int m_nMinX;
int m_nMinY;

int m_nMaxX;
int m_nMaxY;

int m_nCompliance;
int m_nElasticity;

int m_nSpeedX;
int m_nSpeedY;

int m_nMaxSpeed;
int m_nFrictionCoef;
int m_nMomentum;

int i;
int j;

int m_anTouchX[10000];
int m_anTouchY[10000];

bool m_bHorizontalScroll;
bool m_bVerticalScroll;

bool m_bRecoil;
bool m_bFriction;

bool m_bHorizontalSliding;
bool m_bVerticalSliding;

bool m_bActive;

public:

// Constructor
Scroller()
{

}

// This function initiates the scroller and all of its components
void Init(int& container, int touchWidth, int touchHeight, int id)
{
m_nContainer = container;
m_nTouch = TouchAdd(container, 0, 0, touchWidth, touchHeight, OnTouch, id);

m_nX = ContainerGetx(container);
m_nY = ContainerGety(container);

m_nMinX = -touchWidth+320;
m_nMinY = -touchHeight+480;

m_nMaxX = 0;
m_nMaxY = 0;

m_nCompliance = 10;
m_nElasticity = 3;

m_nSpeedX = 0;
m_nSpeedY = 0;

m_nMaxSpeed = 100;
m_nFrictionCoef = 3;
m_nMomentum = 2;

m_bHorizontalScroll = true;
m_bVerticalScroll = true;

m_bRecoil = true;
m_bFriction = true;

m_bHorizontalSliding = false;
m_bVerticalSliding = false;

m_bActive = true;
}

// This function updates the scroller
void Update()
{
/* To update the scroller we're going to:

   1. Check if the x coordinate has changed. If it has, if horizontal
      scrolling is allowed, and if the scroller is active, move the
  container. If the container is out of bounds, and recoil is
  allowed, move the container using compliance. If the container
  is out of bounds, and recoil is not allowed, move the container
  within bounds.

   2. Repeat for the y coordinate.

   3. If nothing has changed, then make the scroller x and y
      coordinates equal to the container's coordinates. This
  is necessary to start scrolling again. If the container
  is out of bounds, slide the container within bounds using
  elasticty.

   4. If friction is allowed, if pressing down, and if the scroller is
      active, set horizontal and vertical sliding off; if moving, store
  the x and y coordinates in an array; if pressing up, check if there
  is vertical or horizontal acceleration and if the acceleration
  surpasses the coefficient of friction. If there is, set sliding on.
   
   5. Vertical and horizontal speed is calculated as the last
      recorded x and y coordinates minus the next to last recorded
  coordinates. If speed exceeds maximum speed, set speed to
  maximum speed.

   6. If horizontal sliding is on, if horizontal scrolling is allowed,
      and if the coordinate is out of bounds, set the speed to zero.
  Otherwise, substract the horizontal speed from the x coordinate.
  Move the container horizontally. If the frame count is divisble
  by the momentum, and if speed is greater than zero, substract
  one from the speed, thus creating friction. If the speed is
  equal to zero, set horizontal sliding off.

   7. Repeat for vertical sliding.
*/

if (nOldX != nNewX && m_bHorizontalScroll && m_bActive)
{
ContainerSetx(m_nContainer, m_nX+nNewX-nOldX);

if (ContainerGetx(m_nContainer) < m_nMinX)
{
if (m_bRecoil)
ContainerSetx(m_nContainer, m_nMinX-(m_nMinX-(m_nX+nNewX-nOldX))/m_nCompliance);
else
ContainerSetx(m_nContainer, m_nMinX);
}

if (ContainerGetx(m_nContainer) > m_nMaxX)
{
if (m_bRecoil)
ContainerSetx(m_nContainer, m_nMaxX-(m_nMaxX-(m_nX+nNewX-nOldX))/m_nCompliance);
else
ContainerSetx(m_nContainer, m_nMaxX);
}
}

if (nOldY != nNewY && m_bVerticalScroll && m_bActive)
{
ContainerSety(m_nContainer, m_nY+nNewY-nOldY);

if (ContainerGety(m_nContainer) < m_nMinY)
{
if (m_bRecoil)
ContainerSety(m_nContainer, m_nMinY-(m_nMinY-(m_nY+nNewY-nOldY))/m_nCompliance);
else
ContainerSety(m_nContainer, m_nMinY);
}

if (ContainerGety(m_nContainer) > m_nMaxY)
{
if (m_bRecoil)
ContainerSety(m_nContainer, m_nMaxY-(m_nMaxY-(m_nY+nNewY-nOldY))/m_nCompliance);
else
ContainerSety(m_nContainer, m_nMaxY);
}
}

if (nOldX == nNewX && nOldY == nNewY)
{
m_nX = ContainerGetx(m_nContainer);
m_nY = ContainerGety(m_nContainer);

if (m_nX < m_nMinX)
SlideContainer(m_nContainer, m_nMinX, m_nY, m_nElasticity);
if (m_nY < m_nMinY)
SlideContainer(m_nContainer, m_nX, m_nMinY, m_nElasticity);
if (m_nX > m_nMaxX)
SlideContainer(m_nContainer, m_nMaxX, m_nY, m_nElasticity);
if (m_nY > m_nMaxY)
SlideContainer(m_nContainer, m_nX, m_nMaxY, m_nElasticity);
}

if (m_bFriction && m_bActive)
{
j++;

if (nTouchEvent == 1)
{
i = 0;
m_bHorizontalSliding = false;
m_bVerticalSliding = false;
}

if (nTouchEvent == 2)
{
i++;
m_anTouchX[i] = nNewX;
m_anTouchY[i] = nNewY;
}

if (nTouchEvent == 3)
{
j = 0;

if ((m_anTouchX[i] > m_anTouchX[i-1] && m_anTouchX[i] - m_anTouchX[i-1] > m_nFrictionCoef) ||
(m_anTouchX[i] < m_anTouchX[i-1] && m_anTouchX[i-1] - m_anTouchX[i] > m_nFrictionCoef))
m_bHorizontalSliding = true;

if ((m_anTouchY[i] > m_anTouchY[i-1] && m_anTouchY[i] - m_anTouchY[i-1] > m_nFrictionCoef) ||
(m_anTouchY[i] < m_anTouchY[i-1] && m_anTouchY[i-1] - m_anTouchY[i] > m_nFrictionCoef))
m_bVerticalSliding = true;

m_nSpeedX = m_anTouchX[i-1] - m_anTouchX[i];
m_nSpeedY = m_anTouchY[i-1] - m_anTouchY[i];

if (m_nSpeedX >= m_nMaxSpeed)
m_nSpeedX = m_nMaxSpeed;

if (m_nSpeedX <= -m_nMaxSpeed)
m_nSpeedX = -m_nMaxSpeed;

if (m_nSpeedY >= m_nMaxSpeed)
m_nSpeedY = m_nMaxSpeed;

if (m_nSpeedY <= -m_nMaxSpeed)
m_nSpeedY = -m_nMaxSpeed;

nTouchEvent = -1;
}

if (m_bHorizontalSliding && m_bHorizontalScroll)
{
if (m_nX < m_nMinX || m_nX > m_nMaxX)
m_nSpeedX = 0;
else
m_nX -= m_nSpeedX;

ContainerSetx(m_nContainer, m_nX);

if (j % m_nMomentum == 0 && m_nSpeedX > 0)
m_nSpeedX--;

if (j % m_nMomentum == 0 && m_nSpeedX < 0)
m_nSpeedX++;

if (m_nSpeedX == 0)
m_bHorizontalSliding = false;
}

if (m_bVerticalSliding && m_bVerticalScroll)
{
if (m_nY < m_nMinY || m_nY > m_nMaxY)
m_nSpeedY = 0;
else
m_nY -= m_nSpeedY;

ContainerSety(m_nContainer, m_nY);

if (j % m_nMomentum == 0 && m_nSpeedY > 0)
m_nSpeedY--;

if (j % m_nMomentum == 0 && m_nSpeedY < 0)
m_nSpeedY++;

if (m_nSpeedY == 0)
m_bVerticalSliding = false;
}
}
}

// This function sets the minimum x range
void SetMinX(int x)
{
m_nMinX = x;
}

// This function sets the minimum y range
void SetMinY(int y)
{
m_nMinY = y;
}

// This function sets the maximum x range
void SetMaxX(int x)
{
m_nMaxX = x;
}

// This function sets the maximum y range
void SetMaxY(int y)
{
m_nMaxY = y;
}

// This function sets the minimum and maximum x and y ranges
void SetBoundaries(int minX, int minY, int maxX, int maxY)
{
SetMinX(minX);
SetMinY(minY);
SetMaxX(maxX);
SetMaxY(maxY);
}

// This function sets the horizontal scroll
void SetHorizontalScroll(bool flag)
{
m_bHorizontalScroll = flag;
}

// This function sets the vertical scroll
void SetVerticalScroll(bool flag)
{
m_bVerticalScroll = flag;
}

// This function sets the recoil
void SetRecoil(bool flag)
{
m_bRecoil = flag;
}

// This function sets the friction
void SetFriction(bool flag)
{
m_bFriction = flag;
}

// This function sets the active state
void SetActive(bool flag)
{
m_bActive = flag;
}
};

#endif

ScrollButton.h
Code: [Select]
/* Copyright 2012 Juan José Sánchez Ramírez

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

   Author Juan José Sánchez Ramírez
   Version 1.0
*/

#ifndef SCROLL_BUTTON
#define SCROLL_BUTTON

// This class creates a button for scrollers
class ScrollButton
{

private:

int m_nContainer;

int m_nId;

int m_nImage1;
int m_nImage2;

int m_nView;
int m_nTouch;

int (*m_pnCallback)(int id);

bool m_bScrolling;

bool m_bRelease;

public:

// Constructor
ScrollButton()
{

}

// This function initiates the list button and all of its components
void Init(int& container, char* filename, int x, int y, int (*callback)(int id), int id)
{
m_nContainer = container;

m_nId = id;

char name[100];

StrCopy(name, filename);
StrAppend(name, "1.png");

m_nImage1 = ImageAdd(name);

StrCopy(name, filename);
StrAppend(name, "2.png");

m_nImage2 = ImageAdd(name);

m_nView = ViewAdd(container, m_nImage1, x, y);

int width = ImageGetWidth(m_nImage1);
int height = ImageGetHeight(m_nImage1);

m_nTouch = TouchAdd(container, x, y, width, height, OnTouch, id);

m_pnCallback = callback;

m_bScrolling = false;

m_bRelease = false;
}

// This function updates the scroller
void Update()
{
if (nTouchId == m_nId)
{
if (nTouchEvent == 1)
{
ViewSetImage(m_nView, m_nImage2);
m_bRelease = false;
}
else
{
ViewSetImage(m_nView, m_nImage1);

if (nTouchEvent == 2)
m_bScrolling = true;

if ((nTouchEvent == 3 && !m_bRelease) || (nTouchEvent == -1 && !m_bRelease))
{
if (m_bScrolling)
m_bScrolling = false;
else
m_pnCallback(m_nId);

m_bRelease = true;
}
}
}
}
};

#endif

App.cpp
http://pastebin.com/pGhA41cy

Download example here:
http://www.mediafire.com/?2ipll7cb2zlxpie

These two classes work with containers, so you need DragonFireSDK v2.0 or above. Initiate every component in the AppMain. Update components in OnTimer. Make sure to give different IDs to every object!

Edit: Changed the code to version 2.2.1. Changed the example to the one in the video.

Hi This code is absolutely awesome. Thank you!

I got the first scroll surface to work, but the second one seems to not slide. So when I swipe, it just follows the finger movement? I have the same code as the first scroll (except that the second one is vertical scroll), so is there something I'm missing?

Thank you in advance

36
Non-Game Programming / Re: Can't hear mp3 files
« on: January 27, 2013, 11:14:52 am »
This probably isnt the problem, but did you put the snd file into the build folder?

37
Game Programming / Re: Anyone have pause icons?
« on: January 27, 2013, 11:13:26 am »
what should the icon do when pressed?

Thanks a lot.

Is this a general question? So, im going to use add the pause icon as a button, which will show a container of buttons to restart level/ undo move etc

Do you have a clicked version of the pause button? Or even a restart button? Thanks for the help!

38
Game Programming / Anyone have pause icons?
« on: January 26, 2013, 02:14:03 pm »
Hello,

I was trying to find some pause icons on google but they don't have the pressed versions!

Would anyone be kind enough to send me their pause (released and pressed) versions?

I would be very grateful (My graphic skills are dreadful - I cant seem to draw the pressed verisons),

Thank you
Micboy

39
How Do I...? / Re: SQL selecting record using a variable?
« on: January 25, 2013, 01:49:02 pm »
Thanks.
If you have separate methods for each button being pressed then you already know field_id will be 1,2...etc so you can just do:
Code: [Select]
sqLiteExec("select fieldname from mytable where field_id=1");
If one method is run for all buttons and field_id can be determined by your x and y coordinates of the user touch then you'll need:
Code: [Select]
Char buffer[200];
Sprintf(buffer, "select fieldname from my table where field_id='%d',field_id");
sqLiteExec(buffer);


Hello,

What is meant by Buffer?

Thank you

40
App Store / Re: Uploading CSR
« on: January 24, 2013, 02:17:30 pm »
Is it a problem if my DFSDK email address is different to my Apple email address?

41
Thanks for the info! Hows the success?
Good luck!

42
Build Center / Re: I have a 1st Gen ipod touch...
« on: January 23, 2013, 03:09:12 pm »
what ios version are you on? it stops on 3.x or something right? if so, then email support  like DeadSn0wMan said...
Yep, it cant go any higher. I asked support and they said its not possible! Thanks for your help!

43
Non-Game Programming / Re: Textbox
« on: January 23, 2013, 02:56:01 pm »
As all of you know, the NoteAdd, although very handy, doesn't allow the use of other fonts, just that horrible Arial size 16 (I'm just guessing here, by the way). So I created a new class to add multi-line textboxes. The only problem? It doesn't allow more than 255 characters per textbox. Why? Because that is as many characters as you can put in a string. Other than that, it works perfectly. It's rough, and could probably use some editing. Also, it works by using font images, so you'll have to create your fonts to use this. It's better than nothing. Right?

Textbox.h
Code: [Select]
/* Copyright 2012 Project Coral

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

   Author Juan José Sánchez Ramírez
*/

#ifndef TEXTBOX_H
#define TEXTBOX_H

#include <string.h>

class Textbox
{
private:

int lines[32];
int current_page;
int text_font;
int m_container;
int m_image;
int m_view;
int m_x;
int m_y;
int m_width;
int m_height;
char* m_text;
char* m_font;

int GetCharHeight()
{
char string[100];
StrCopy(string, m_font);
StrAppend(string, "/F032.png");
int image = ImageAdd(string);
return ImageGetHeight(image);
}

int GetMaxLines()
{
return m_height / GetCharHeight();
}

int GetCharWidth(char letter)
{
int image;

char file[100];
char string[100];

switch (letter)
{
case ' ':
StrCopy(string, "F032");
break;
case '!':
StrCopy(string, "F033");
break;
case '$':
StrCopy(string, "F036");
break;
case '%':
StrCopy(string, "F037");
break;
case '&':
StrCopy(string, "F038");
break;
case '\'':
StrCopy(string, "F039");
break;
case '(':
StrCopy(string, "F040");
break;
case ')':
StrCopy(string, "F041");
break;
case '*':
StrCopy(string, "F042");
break;
case '+':
StrCopy(string, "F043");
break;
case ',':
StrCopy(string, "F044");
break;
case '-':
StrCopy(string, "F045");
break;
case '.':
StrCopy(string, "F046");
break;
case '/':
StrCopy(string, "F047");
break;
case '0':
StrCopy(string, "F048");
break;
case '1':
StrCopy(string, "F049");
break;
case '2':
StrCopy(string, "F050");
break;
case '3':
StrCopy(string, "F051");
break;
case '4':
StrCopy(string, "F052");
break;
case '5':
StrCopy(string, "F053");
break;
case '6':
StrCopy(string, "F054");
break;
case '7':
StrCopy(string, "F055");
break;
case '8':
StrCopy(string, "F056");
break;
case '9':
StrCopy(string, "F057");
break;
case ':':
StrCopy(string, "F058");
break;
case ';':
StrCopy(string, "F059");
break;
case '<':
StrCopy(string, "F060");
break;
case '=':
StrCopy(string, "F061");
break;
case '>':
StrCopy(string, "F062");
break;
case '?':
StrCopy(string, "F063");
break;
case '@':
StrCopy(string, "F064");
break;
case 'A':
StrCopy(string, "F065");
break;
case 'B':
StrCopy(string, "F066");
break;
case 'C':
StrCopy(string, "F067");
break;
case 'D':
StrCopy(string, "F068");
break;
case 'E':
StrCopy(string, "F069");
break;
case 'F':
StrCopy(string, "F070");
break;
case 'G':
StrCopy(string, "F071");
break;
case 'H':
StrCopy(string, "F072");
break;
case 'I':
StrCopy(string, "F073");
break;
case 'J':
StrCopy(string, "F074");
break;
case 'K':
StrCopy(string, "F075");
break;
case 'L':
StrCopy(string, "F076");
break;
case 'M':
StrCopy(string, "F077");
break;
case 'N':
StrCopy(string, "F078");
break;
case 'O':
StrCopy(string, "F079");
break;
case 'P':
StrCopy(string, "F080");
break;
case 'Q':
StrCopy(string, "F081");
break;
case 'R':
StrCopy(string, "F082");
break;
case 'S':
StrCopy(string, "F083");
break;
case 'T':
StrCopy(string, "F084");
break;
case 'U':
StrCopy(string, "F085");
break;
case 'V':
StrCopy(string, "F086");
break;
case 'W':
StrCopy(string, "F087");
break;
case 'X':
StrCopy(string, "F088");
break;
case 'Y':
StrCopy(string, "F089");
break;
case 'Z':
StrCopy(string, "F090");
break;
case '{':
StrCopy(string, "F091");
break;
case '\\':
StrCopy(string, "F092");
break;
case '}':
StrCopy(string, "F093");
break;
case 'a':
StrCopy(string, "F097");
break;
case 'b':
StrCopy(string, "F098");
break;
case 'c':
StrCopy(string, "F099");
break;
case 'd':
StrCopy(string, "F100");
break;
case 'e':
StrCopy(string, "F101");
break;
case 'f':
StrCopy(string, "F102");
break;
case 'g':
StrCopy(string, "F103");
break;
case 'h':
StrCopy(string, "F104");
break;
case 'i':
StrCopy(string, "F105");
break;
case 'j':
StrCopy(string, "F106");
break;
case 'k':
StrCopy(string, "F107");
break;
case 'l':
StrCopy(string, "F108");
break;
case 'm':
StrCopy(string, "F109");
break;
case 'n':
StrCopy(string, "F110");
break;
case 'o':
StrCopy(string, "F111");
break;
case 'p':
StrCopy(string, "F112");
break;
case 'q':
StrCopy(string, "F113");
break;
case 'r':
StrCopy(string, "F114");
break;
case 's':
StrCopy(string, "F115");
break;
case 't':
StrCopy(string, "F116");
break;
case 'u':
StrCopy(string, "F117");
break;
case 'v':
StrCopy(string, "F118");
break;
case 'w':
StrCopy(string, "F119");
break;
case 'x':
StrCopy(string, "F120");
break;
case 'y':
StrCopy(string, "F121");
break;
case 'z':
StrCopy(string, "F122");
break;
case '~':
StrCopy(string, "F126");
break;
default:
StrCopy(string, "F032");
break;
}

StrCopy(file, m_font);
StrAppend(file, "/");
StrAppend(file, string);
StrAppend(file, ".png");

image = ImageAdd(file);
return ImageGetWidth(image);
}

int GetTotalLines()
{
char text[255];
sprintf(text, m_text);
char* token;
char* pch;
char separators[] = " \n";
token = strtok_s(text, separators, &pch);

int lines = 1;
int total_width = 0;
while (token != NULL)
{
int token_width = 0;
for (int i=0; i<(int)strlen(token); i++)
{
char letter = token[i];
token_width += GetCharWidth(letter);
}
token_width += GetCharWidth(' ');

if (total_width + token_width > m_width)
{
total_width = token_width;
lines++;
}
else
total_width += token_width;

token = strtok_s(NULL, separators, &pch);
}

return lines;
}

int GetTotalPages()
{
int total_pages;
if (GetTotalLines() % GetMaxLines() == 0)
total_pages = GetTotalLines() / GetMaxLines();
else
total_pages = GetTotalLines() / GetMaxLines() + 1;

return total_pages;
}

char* GetLineText(int current_line)
{
char* line = new char[255];
char text[255];
sprintf(text, m_text);
char* token;
char* pch;
char separators[] = " \n";
token = strtok_s(text, separators, &pch);

int lines = 0;
int total_width = 0;
while (token != NULL)
{
int token_width = 0;
for (int i=0; i<(int)strlen(token); i++)
{
char letter = token[i];
token_width += GetCharWidth(letter);
}
token_width += GetCharWidth(' ');

if (total_width + token_width > m_width)
{
total_width = token_width;
lines++;
}
else
total_width += token_width;

if (lines / GetMaxLines() == current_page &&
lines % GetMaxLines() == current_line)
{
if (total_width == token_width)
StrCopy(line, token);
else
StrAppend(line, token);
StrAppend(line, " ");
}

token = strtok_s(NULL, separators, &pch);
}

return line;
}

void PrintLine(int i)
{
char* text = GetLineText(i);
TextSetText(lines[i], text);
}

void PrintPage()
{
char* text = "                                                                ";
for (int i=0; i<GetMaxLines(); i++)
TextSetText(lines[i], text);
int total_lines;
if (current_page == GetTotalPages()-1)
{
if (GetTotalLines() % GetMaxLines() == 0)
total_lines = GetMaxLines();
else
total_lines = GetTotalLines() % GetMaxLines();
}
else
total_lines = GetMaxLines();
for (int i=0; i<total_lines; i++)
PrintLine(i);
}

public:

int GetX()
{
return m_x;
}

int GetY()
{
return m_y;
}

int GetWidth()
{
return m_width;
}

int GetHeight()
{
return GetCharHeight();
}

int GetLines()
{
return GetTotalLines();
}

void Init(int &container, int image, int view, int x, int y, int width, int height, char* text, char* font)
{
m_container = container;
m_image = image;
m_view = view;
m_x = x;
m_y = y;
m_width = width;
m_height = height;
m_text = text;
m_font = font;

current_page = 0;
text_font = FontAdd(m_font);

char str[64];
for (int i=0; i<GetMaxLines(); i++)
{
int x = m_x;
int y = m_y + i*GetCharHeight();
lines[i] = TextAdd(m_container, x, y, str, text_font);
}

PrintPage();
}

int NextPage()
{
int page = 0;
if (current_page < GetTotalPages()-1)
{
current_page++;
page = current_page;
}
else
page = -1;
PrintPage();
return page;
}


void SetText(char* text)
{
m_text = text;
current_page = 0;
PrintPage();
}
};

#endif

Here's how to use it. It's super simple. Also, you don't really need the image and the view, you can just set those to 0. The other numbers are x and y coordinates, width and size. You can change the text using the SetText function. I told you it was super simple. There're some other functions there, like GetX, GetY, GetWidth, GetHeight, GetLines, which I just included for general purposes. The one function you should really learn how to use in NextPage. If the text is too big for one textbox, you can call NextPage to print out the next set of lines. Magnificent. Right?

Anyhow, keep your character count to less than 255 and your line count to less than 16.

Code: [Select]
Textbox textbox;
textbox.Init(nContainer, TextboxImage, TextboxView, 8, 72, 304, 356,
"Hath not a Jew eyes? Hath not a Jew hands, organs, dimensions, senses, affections, passions; fed with the same food, hurt with the same weapons, subject to the same diseases, heal'd by the same means, warm'd and cool'd by the same winter and summer as a", "Fonts/Arial12RegularBlack");

Looks great JJ!

44
Tips and Tricks / Re: DragonFireSDK Undocumented Function: AlertShow()
« on: January 23, 2013, 02:54:47 pm »
Sorry, im a bit new to this!
Should I add the code as shown by Tim into a header file?
Also, will I get an email for the 2.2 update?

45
Hey Guys,

 Just got my app written with DragonFireSDK into the itunes store. It's free so check it out and give me a review if you have time. I published the first version thru Zimusoft just to see if I get any interest in it. The next version will be a 99 cent version with the more options (choice of foods, levels, GameCenter Support ect.). I'm just curious if anyone doesn't mind sharing, what kind of download numbers are you guys getting? Other developers here might also be interested. Here is the link https://itunes.apple.com/us/app/pignout/id593674593?mt=8

EricB

Looks good!

Jut wondering if its possible to withdrw an app from  zimusoft after a while?
Also, did you store the highscore in an external document as shown in the wiki?
By the way, how many lines of code do the dfsdk apps end up being?

Keep it up! Sadly i only have a ipod touch 1st gen, so unable to download! But ill definitely let my friends know about this app to get you some downloads!

Pages: 1 2 [3] 4 5 6