Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I can't belive I'll say this, but I actually tried to programm some basic physics. The only reason why I did this is that I wanted to create a runner game for my phone since going to PlayMarket... Uhh, let's don't talk about that. SO, despite the fact that this formula works, I have a bit of a problem though. The jump itself is an action, and this action has a function that is being registered on frame. Everything is fine, until the moment my character lands. When it does reach 0 units by Y axis (h <= 0), the position is changed to 0,0,0 (the game doesn't feature built-in collision behavior, so, yeah, that's the reason for this to be). And that's when I noticed something: it doesn't work bruuuuuuuuuuuuuuuuuuu... Speaking of "doesn't work", I don't know what is wrong... Yeah, so, um-m, I guess I should ask help about that. Here's the code to understand better: /* As far as I know, there is some stuff like "retrun true" or "return false" does exist, but I still don't understand how does these things work and how to use them. |
||||
|
The return statement ends function execution and specifies a value to be returned to the function caller. /* |
||||
|
I code in a simple style. I could never wrap my head around the way you guys are doing stuff. Prototype? I even don't know what that's good for. I use: function myfunction() { do something } ccbRegisterOnFrameEvent(myfunction); Works flawlessly for me. That said, it's called in the before-first-drawing behavior. Besides, notice this will not stop when the scene is switched. It's continued, and I'm not sure if scenenodes of the same name inside different scenes could cause mayhem. |
||||
|
To sven: Woah, this kinda works... Can't say that I really understood what caused it, but, uh-h... Whatever, as someone said once: It just works Yet again, thanks for help. To csp-games: Well, actually, I don't know which way is simplier or not, I came here with no programming knowlege at all (some Pascal lessons from scool doesn't count), so, I am doing the stuff like most of the people do. Hell, my first scripts were just a combination of parts from other scripts by other people. So, I might be doing something in a not very simple or a good way. |
||||
|
While I keep on using code that others deem to be no longer good style. Yet it works. Sometimes better than all the sophisticated stuff. The thing with JS is, you can use many different styles. Whether you say "i++;" (that's C++) or "i=i+1;" (that's BASIC), it works both ways. Readability is important to me. And I wanna stay in control, so I rarely use "For Each" and stuff like that. Even array.length I use rarely, but would rather know already the size of an array, because I have made it. BTW did I mention that I personally know the guy who made Pascal? Professor Nick Wirth. |
|