Getting started iphone help

Game Editor comments and discussion.

Getting started iphone help

Postby maker151 » Tue Nov 22, 2011 12:02 am

Hi there,

I am making a basic iPhone game for practice and was just wondering. i am also new to game editor and have a very basic understanding of code
- How do i make an actor move continuously backwards?
-I want to add a command where if u touch the iPhone screen u will jump and if you touch it again while jumping you will double jump. how do i manage this??
- how do i keep track of the total number of frames that have transpired in one game. like a text box that will count the number of frames while playing
- the final question is i want to randomly generate actors in an array but so that they will be in a random position yet still relativity close that u can still jump between them continuously. the array also has to be unlimited to the actors will always be continuously generated.

Any help would be appreciated thanks
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Tue Nov 22, 2011 10:16 am

Kind of busy, so for a couple of these I'll just describe the general idea. Do ask if you want anything clarified.

To make an actor move continuously backwards, add this event (change the 10 to whatever speed you want).
actor -> Create Actor -> Script Editor
Code: Select all
xvelocity=-10;


For the jump/double jump, you'll need a variable to store what jump the actor is using. So, when the variable equals 0, that means they can jump. When you do click it sets jump to 1, meaning they have jumped once, so that way you can tell it to do a second jump. To receive the event, you'll need a filled region actor to stretch across the view, and most likely parent it to the view. Then you can add an event like this.
Code: Select all
switch(jump_var)
{
    case 0: // no jump
    jump_var=1;
    /* code for jump, for instance
    player.yvelocity=-15;
    ChangeAnimation("player", "jump", ... Put full ChangeAnimation here */
    break;

    case 1: // already jumping
    jump_var=2; // in double jump
    code for double jump
    break;
}

You'll also need an event to set jump_var back to 0 when you land on the ground.

Next, there is a variable called frame. It stores the current frame, so if you wanted a text actor to display it you can use this.
text_actor -> Draw Actor -> Script Editor
Code: Select all
textNumber=frame;


Last one, I'd suggest searching the forums for random level generation, or similar. There are different ways you can do it, and it really depends on the mechanics of your game, but that should get you going in the right direction.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Tue Nov 29, 2011 3:52 am

hey, sorry for not replying for a while. thank you so much for the help.
just need to clarify a couple of things. What type of actor do i need to create for the frame counter and can i store this number even if the game finishes even?

Also did that code for jump and double jump include the velocity and direction and will the animations repeat or should i put in a fall animation of 1 frame??

thanks
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Tue Nov 29, 2011 8:28 am

maker151 wrote:What type of actor do i need to create for the frame counter and can i store this number even if the game finishes even?

A text actor is a normal actor, with a font and text attached to it. To make a text actor, create a normal actor, then in the actor control panel click text. Type some default text into the large window (you have to do this), and then click the font area to set what font you want to use. If you do that, then you can now use the actor as a text actor (so adding that code will work).

Now, to store that number after the game closes, you'll need to save the variable. You can use file io, or gE's saveVars/loadVars. One thing though is that you'll either need to save the new frame value every frame, or know when the game closes. If you can know when the game closes, I'd suggest using that (since you only have to save it once at the end). To use saveVars, you'll need to create a variable which in this case I'll just call it save_frame (also when creating it, under save group, put save_group). Wherever you put the ExitGame code, add this event (I'm just using the keydown escape as an example).
view -> Key Down Esc -> Script Editor
Code: Select all
save_frame=frame;
saveVars("save_file", "save_group");
ExitGame();

That will save the frame value into the file, save_file. You can use the reverse to load it.

maker151 wrote:Also did that code for jump and double jump include the velocity and direction and will the animations repeat or should i put in a fall animation of 1 frame???

I'm pretty sure you know/can figure out the answer to that question. One thing though is that the text inside the /* */ symbols are what we called commented out. gE will ignore anything within those characters. So I put the yvelocity code in there, to show that you do need to have the code for yvelocity and other things you would need for jump (like ChangeAnimation). But, I left them for you to put in, since you know how high you want the actor to jump, and the animations you wanted it to change to. Now, you can make the fall animation one frame if you want, or you could set it to an animation and create an animation finish event, that stops the fall animation at the last frame. That way the animation won't repeat.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Wed Nov 30, 2011 5:48 am

with the double jump, is the variable declared, i thought you had to put "int jump_var" and what event should i place for the filled actor region for the script editor (which mouse event?) or the global code.
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Wed Nov 30, 2011 8:22 am

You need the jump variable declared in global space. If you declare a variable in an event (like the mouse button down event) the variable is not accessible outside the event, and won't save the value after the event. But, if you make the variable a global variable (by putting it in global code) it will work. So, you can add this.
Global Code
Code: Select all
int jump_var;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Thu Dec 01, 2011 12:00 am

i dont know how to change animation in global space, what is the function for for it, how do i stop it repeating and i just put y velocity in for movement(im concerned because he will just keep going up, how to pause him for like 2 frames in midair before returning to planks or floors actor)
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Thu Dec 01, 2011 1:33 am

Why would you change the animation in global space? Global code is only for declaring things, not for executing actual code. So, in a global script, you can declare variables and functions, but to execute any code declared in global space, you have to do so through a function. That being said, I don't see any reason for you to need to use global space besides declaring that variable. The only function that can change the animation of an actor is the ChangeAnimation function.

Now by repeating do you mean the animation? Or the yvelocity? The mouse button down event will not repeat, so the yvelocity is only set when you click. But, if you don't implement gravity (yvelocity++; in the actor's draw) then they will keep rising forever. It sounds like you haven't implemented a form of gravity, which is supposed to be what keeps the actor on the ground. And, if you want the animation not to repeat, you can use the animation finish event, with the ChangeAnimationDirection function.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Thu Dec 01, 2011 4:36 am

i can implement gravity with that code but then he wont stay on the levels. also, how does that make him come down after jumping or double jumping?
Last edited by maker151 on Thu Dec 01, 2011 7:35 am, edited 1 time in total.
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Thu Dec 01, 2011 7:33 am

I'd recommend going through the caveman platformer tutorials that are built into gameEditor. They cover the basics, and probably would help you understand better how you make a platformer. But, to answer your question, it is just as I've said (yvelocity++; in the draw actor).
actor -> Draw Actor -> Script Editor
Code: Select all
yvelocity++;

That code will keep accelerating the actor downwards. You'll need to have a collision event with the ground to prevent it from falling through (most people use PhysicalResponse in the collision event).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Thu Dec 01, 2011 7:44 am

yeah sorry i realized as i was scrolling, ill check on that source code and ask for any clarifications. thanks
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby maker151 » Sat Dec 03, 2011 12:02 am

hey the actor doesnt work, the animations continuosly repeat and i have a landing animation, how do i implement these??
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Sat Dec 03, 2011 1:38 am

If you don't want an animation to repeat, add an animation finish event for that animation, and add this code.
Code: Select all
ChangeAnimationDirection("Event Actor", "STOPPED");

That will prevent the animation from repeating. Now, a landing animation? Do you want this to trigger before they hit the ground? If so that'll be a bit tricker. Otherwise, you can add a collision event (don't repeat) with the top side of ground, and have a ChangeAnimation to your landing animation.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Getting started iphone help

Postby maker151 » Sun Dec 04, 2011 5:50 am

umm, ok how do i do change from the landing animations to running again and the double jump will not reset itself back to running, e.g i will do a normal jump and land and then i will click again and he will do the double jump without the first jump and fall through the platforms
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Sun Dec 04, 2011 7:17 am

I suggest you learn the code that you implement. Do you understand how the double jump code works? I mentioned in that post that when you land on the ground, you need to set it back to 0. That will fix the double jumping. As for your changing animations, since you are using a constant movement game, all you want is that at the end of the landing animation, you start running again, right? Well, then use an animation finish event, that does just that.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest