Getting started iphone help

Game Editor comments and discussion.

Re: Getting started iphone help

Postby maker151 » Fri Dec 09, 2011 4:48 am

hey, whats wrong with this code, i cant get it to work
switch(jump_var)
{
case 0:
jump_var=1;
player.yvelocity=-15;
ChangeAnimation("player", "jump", FORWARD);
ChangeAnimationDirection("player", STOPPED);
break;


case 1:
jump_var=2;
ChangeAnimation("player", "double jump", FORWARD);
ChangeAnimationDirection("player", STOPPED);
player.yvelocity=-15;
break;
}


then i added this code
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);
ChangeAnimation("player", "land", FORWARD);
jump_var = 0;

i added an animation finish event and it would not work or it would but in a weird way, what have i done wrong??
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Fri Dec 09, 2011 5:06 am

You're going to have to be more descriptive than that. What do you mean it would not work? Define weird. I assume that event (the one with the PhysicalResponse) is a collision no repeat enabled 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 » Sun Dec 18, 2011 10:21 am

hey sorry for the wait laptop crashed, umm okay, ur assumption is correct, the part that goes wrong is when i land and the then change the animation to running the player goes into a weird spasm instead of landing and running. also, when i clone the planks on a basic array the physical response sometimes fails
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 18, 2011 10:38 am

Okay, well your collision code for setting the animation needs to set to not repeat. But, you'll also need a collision event with the PhysicalResponse that is set to repeat. The animation spasm problem you are having is due to that ChangeAnimation call being triggered every frame that they player collides with the ground. The falling through might be due to the direction of collision.
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 22, 2011 1:03 pm

i set the change animation event not to repeat on the collision but it still spasms... y is that happening???
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 22, 2011 8:12 pm

Ah, I forgot your land animation is different than your run animation. Try this, you might need to adjust the yvelocity value depending on the gravity of your game.
Code: Select all
if(yvelocity>3)
{
    ChangeAnimation("player", "land", FORWARD);
}
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_CALCULATED_MASS, 1.000000, 1.000000, 0.000000, 1.000000);
jump_var = 0;

The idea is that if you are falling onto the platform, your yvelocity should be greater than 1 or 2, and you should change animation to land. Otherwise you should just have the collision event (no change animation). I usually use the state method, which would allow you to specify only change the animation if you are falling, but this should do the trick as well.
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 » Fri Dec 23, 2011 12:46 am

hey thanks that worked well, how do i fix the random physical response failing. i dont know what to do for that
maker151
 
Posts: 15
Joined: Sat Nov 19, 2011 10:37 am
Score: 0 Give a positive score

Re: Getting started iphone help

Postby skydereign » Fri Dec 23, 2011 12:51 am

How fast is your actor moving? If it is moving faster than half the tile's width, then you can't fix it with PhysicalResponse. But, perhaps it is due to you not having collisions with the tile's left or right side. It's kind of hard to diagnose without seeing your game.
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 » Sat Dec 24, 2011 12:29 am

ok, i added physical responses to left and right side but there was still no change, how do i fix that first problem u described, im not sure how to with out the physical response
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 24, 2011 5:48 am

Well actually it isn't quite as extreme as half the width, I forgot to factor in the actor itself. So, half the width of the tile, and half the width of the actor. Anything faster has the capability to fail. And there isn't a good fix for this. You can use larger tiles, create filled regions for collisions, or develop your own collision system. There are potentially even more little cheap things you can do to improve the chances of catching a collision, but nothing will be as concrete as you creating your own system. One usual fix is to prevent yvelocity from ever getting that high. You'd usually set the max to a comfortable distance less than that yvelocity. Is the player's yvelocity greater than half the sum of the player and tile's width? Otherwise you'll need to give me more to work with.
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 Dec 28, 2011 7:12 am

its all good, i fixed the problem, i was wondering i searched and could not find anything on random actors generating along an array, to be specific, i need to randomize the x space(distance) but create my landing platforms on one consistent y coordinate while having different animations of the actor randomly chosen. also, im curious why did that "if statement" of the y velocity change the animation to work perfectly??
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 Dec 28, 2011 7:29 am

Pretty much anything random is done with the rand function. If you want to spawn things on the x axis, with random distances between them then you can do so by looping CreateActor with the same y, and a random x. For instance, you can do something like this.
Code: Select all
int i;
for(i=0;i<20;i++)
{
    CreateActor("actor", "anim", "(none)", "(none)", i*100+rand(50), height/2, false);
}

They'll be created at relatively uniform intervals, but have a random aspect. But, if you want truly random instead of progressively created, you can just use rand instead of the for loop.
actor.0 (000-050, 240)
actor.1 (100-150, 240)
actor.2 (200-250, 240)
actor.3 (300-350, 240)
and so on...

To have them have random animations you can add this event. All you'd need to change is num_of_animations to the actual number of animations the actor has.
actor -> Create Actor -> Script Editor
Code: Select all
ChangeAnimation("Event Actor", getAnimName(rand(num_of_animations)), FORWARD);


Now, the if statement worked because when yvelocity is greater than whatever you set it to, that means the actor is falling. Because of the actor's gravity in its draw script, it will constantly be falling even while it is on the tiles, but it is also constantly colliding with the ground, and therefore reseting its yvelocity. If the actor was able to fall for 2-3 frames, then yvelocity would be greater than three, and therefore you would want a landing animation to activate. If the actor hadn't been falling for more than two frames, that means they have been running on tiles and you don't want to trigger the animation change.
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 Dec 28, 2011 10:46 am

how do i implement each bit of 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 » Thu Dec 29, 2011 12:11 am

Which leads me to believe you don't know what the code is doing? I prefer having you understand the code, than me just giving it out. If you know a bit of code's function, you can figure out where it goes. That first bit creates 20 tiles spaced somewhat randomly about. Where would you want to spawn 20 randomly spaced tiles? You might put it in the view's create actor event, or a mouse button down event for a menu. In the case of the mouse button down event, you'd have to change the code a tad though. And the other bit of code I already told you where to put it.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Previous

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest