What's wrong here, eh?[SOLVED]


(I'll tell you what I want, what I really really want) #1
		if (_tytul.y >= 300)
		{
			_tytul.y += 10 * FP.elapsed;
		}
		else if (_tytul.y <= 320)
		{
			_tytul.y -= 10 * FP.elapsed;
		}

Trying to move a title (tytul) by 20 pix down, and then the same number going up, and it just keeps on going down.

I just cannot understand what I’m doing wrong. I’m just an amateur, so please don’t kill me for another noob thread if it’s obvious :smile:


(azrafe7) #2

Well… it’s actually pretty obvious why it keeps going down. :wink:

Just a hint: you should try to execute the snippet in your mind to see why it does so, and think about what if branch will be run based on their conditions.


(Martí Angelats i Ribera) #3

I was going to say your error but it’s ovbious… I won’t say it becouse this way you’ll learn more.

PD: Let’s give him 1 tip per day… the first one have been already gived.


(I'll tell you what I want, what I really really want) #4

Done.

		_tytul.y += speed * FP.elapsed;
		
		if (_tytul.y > 310)
		{
			speed *= -1;
			_tytul.y = 310;
		}
		if (_tytul.y < 300)
		{
			speed *= -1;
			_tytul.y = 300;
		}

Case closed, thank you guys.


(I'll tell you what I want, what I really really want) #5

Another problem, but I’m motivated.

Can anyone please tell me why this,

		if (Input.check(Key.SPACE))
		{
			FP.world = new TutorialLevel;
		}

where Tutorial Level is an empty world: makes everything from the current world disappear . Instead of all the Texts all I have is one background Image. And a backdrop that’s not moving.


(Martí Angelats i Ribera) #6

Using FP.world = new TutorialLevel; you’ve set the world that’s rendering (the FlashPunk ONLY renders the FP.world). So you set a void world to render so gess what, nothing is rendered.

PD: I think you need some more general knowlage or you will have tones of this problems. I recomend to follow some tuturials.


(I'll tell you what I want, what I really really want) #7

I don’t think knowledge is the problem here, it’s practice, I’ve read tons of articles, and If you don’t want to help bro, just don’t respond, ignore the post :smile:

And by the way, if I set FP.world = to some other world, it’s all working.

Another btw, problem sorted.


(Martí Angelats i Ribera) #8

I actually didn’t understand your problem. If you set an empty world to FP.World it won’t render anything. If it’s not empty, then the problem could be in that TutorialLevel class.

PD: And i actually anwered your problem in the first line :confused: I’m here to help and i’m sorry if this offended you but i have to talk, and try to help you, without a deep knowlage of the case. Next time show some.

I recomended (and it’s only a recomendation, i don’t know your case enough) you to follow (and not only read) a tutorial that makes an easy game wich have everything you’ll need (but to be effective you have to understand what are you doing).

You can also, if you like to do this kind of things, look at the FlashPunk code to see how it exactly works.

PD2: You can actually use ``` actionscript and closing it with ``` to put code. This will be preattier and easier to understand.