perezbalen's Forum Posts

  • Hi

    I have problems understanding what javascript is doing.

    I have this code:

    <font face="Courier New, Courier, mono">

    Acts.prototype.MakeDungeon = function (text_value, mapSizeX, mapSizeY)

         {       

              this.testFunction(2,2); //This works

                  Acts.prototype.MakeCustomDungeon (text_value, mapSizeX, mapSizeY, 5, 15, 150, 50);

         };

         

         Acts.prototype.MakeCustomDungeon = function (text_value, mapSizeX, mapSizeY, roomMinSize, roomMaxSize, roomMaxArea, roomsMaxNum )

         {       

              this.testFunction(2,2); //This DOESN?T works

         };

         

         instanceProto.testFunction = function (x,y)

            {

                     //do stuff

            }</font>

    I have two Acts that can be called from the editor. One has more options than the other, so when I call <font face="Courier New, Courier, mono">MakeDungeon</font>, it itself calls <font face="Courier New, Courier, mono">MakeCustomDungeon</font> and gives default values to the missing information.

    The thing is that when I call <font face="Courier New, Courier, mono">this.testFunction</font>, it works only from the <font face="Courier New, Courier, mono">MakeDungeon</font>, and not the <font face="Courier New, Courier, mono">MakeCustomDungeon</font>.

    When the <font face="Courier New, Courier, mono">this.testFunction</font> is called from <font face="Courier New, Courier, mono">MakeCustomDungeon</font> (via <font face="Courier New, Courier, mono">MakeDungeon</font>), I get an error message:

    <font face="Courier New, Courier, mono">Javascript error! TypeError: this.testFunction is not a function</font>

    Can someone help me figure out what?s going on?

  • Apparently, I had to declare the function like this:

    instanceProto.testFunction = function (x,y)

         {

              //do stuff

         };

  • Hi

    I�m exploring the plugins SDK, and have hit a roadblock.

    I managed to get my plugin running. I�ve managed to create new Actions; like this one:

    <font face="Courier New, Courier, mono">

    Acts.prototype.DoSomething = function (text_value, X, Y)

         {

              var i,j;

              for (i=1; i < X; i++)

              {

                   for (j=1; j < Y; j++)

                   {

                       testFunction(i,j);

                   }

              }

         };

    </font>     

    But I can�t figure out how to do functons. In this example, testfucntion (i,j).

    I made it like this:

    <font face="Courier New, Courier, mono">

         this.testFunction = function (x,y)

         {

              //do stuff

         };

    </font>

    But it doesn�t work. How can I white a function,or aprivate method, or some code that the Acts.prototype.DoSomething can use?

    Thanks.

  • Hi

    Is there a way to use conditions in for loops, like:

    <font face="Courier New, Courier, mono">for (int ytemp = y; ytemp > (y-ylen); ytemp--)</font>

    Or at least a way to have the loop count backwards, like from 10 to 1 (instead of form 1 to 10) ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • THanks for the replies.

    I'm building art on the fly for random generated lavels, and I read that the tiled object was less expensive than the sprites, so that's why I asked.

    I was wondering if COnstruct has a feature that lets you pre-render images before they are used in the game (so I don�t need to place one sprite on top of the other)

  • Hi

    The original half life used a tecnique to make rocks texture appear less tiley. They had 8 (or something) very similar looking -yet different- tiles, that all conected to each other. And when applying this to a rock wall, the engine would randomly choose a tile every "square" instead of using the same tile every time.

    so far, I`ve been able to replicate this effect in Construct 2 using sprites, but was wondering if there is a way to do this using Tiled backgrounds.

    Thanks.

  • Thanks. That did the trick.

  • Hi

    I�m having this problem: When my player runs, it�s catching the bullet he just fired, and being hit by it.

    Is there a way to know which object spawned another object, so I can set my bullet to ignore the collision with the object who spawned it?

    Thanks.

  • Hi I have the following event:

    Enemy On collision with Enemy.

    and the action should do something, like have the first Enemy turn right, and the second turn left (in this example, when enemies collide, they change direction).

    My question is, how do I reference the first enemy and/or the second, in the action "code"?

  • My characters hit like this:

    <img src="http://s23.postimg.org/6rs98ikyz/Screenshot_11.png" border="0" />

    After the attack buttn is pressed:

    1. They get ready for 0.05 seconds.

    2. They hit for 0.1 seconds

    3. They recover their bearings for 0.2 seconds.

    They are supposed to be vulnerable for the time they are getting ready and the time they are recovering.

    The idea I?m trying to do is that if they are hit while they are "getting ready" (that 0.05 seconds), they can?t hit (the enemy?s hit cancels theirs).

    My question is, how can I cancel the attack sequence so that the player hit is canceled (and replaced with a "being hit" animation)?

    Thanks

  • thanks haifisch.

    By the way, why do you disable the platform behavior at the beginning of the hit?

  • Thanks.

    Solved it with the Pin behavior.

  • Thanks. Solved it with Vector Y = -300 on key release.

  • Hi

    Is there a way to force an animation to play all frames, before it allows the game to do anything (for example, to stop player input from moving the playerbox or from another event to trigger another animation)?

    Thanks

  • Update: I added a wait event in between animations, and it kinda works. The thing now is that if I press constantly the attack button, the commands start on top of each other, effectively negating the cool down period.