R0J0hound's Forum Posts

  • Have a look at the SpriteFont.TextHeight expression. If it's less than SpriteFont.Height then all the text fits in the box.

    To set the scale to fit all the text you could do an iterative approach with a loop. Basically it tries a scale of 1.0, sees if the text fits and if it does stop the loop. If it doesn't

    repeat 100 times

    ---> spritefont: set scale to (100-loopindex)/100

    --- spritefont: height > spritefont.textheight

    ------> stop loop

    Here's an example:

    https://dl.dropboxusercontent.com/u/542 ... t_fit.capx

  • 1) the bullet behavior would work fine.

    2) just set the bullet's speed angle of motion and gravity, but you could do whatever.

  • It should be everything, at least for the system and official plugins. If anything doesn't then that would be a good reason for a bug report.

    For third party plugins it depends if the author implemented that part or not. I know for example most of my plugins don't impliment saving and loading, but I guess that's on me.

  • Maybe something like this to save if you just want to save positions.

    Set array size to (Sprite.count, 2, 1)

    For each Sprite

    --- set array at (loopindex, 0) to Sprite.x

    --- set array at (loopindex, 1) to Sprite.y

    Then maybe this to load:

    Array: for each X

    --- create Sprite at array.at(array.curx,0), array.at(array.curx,1) )

  • Just use multiple layouts. No need to deal with xml or databases.

  • You could use a global variable I suppose. I don't know when you make it jump, so for example every second you could do this.

    Global number move=0

    Every 1.0 seconds

    --- simulate jump

    --- set move to 1

    --- wait 0.5 seconds

    --- set move to 0

    Move = 1

    --- set velocityX to 100

  • I can't open your capx atm, but the every tick event is where you set the starting X,y, and velocities. In what I typed about it uses a object called cannon's position and angle.

  • The idea there is we need to keep the object's y position below the starting y. If the object goes above the sqrt in the equation will make the speed NaN because you can't get the square root of a negative number.

  • Here's one for the physics behavior:

    But you can do it without with simply:

    global number gravity=1000

    global number speed=200

    global number step=0.1

    global number vx=0

    global number vy=0

    global number x=0

    global number y=0

    every tick

    --- dot: destroy

    --- set x to cannon.x

    --- set y to cannon.y

    --- set vx to speed*cos(cannon.angle)

    --- set vy to speed*sin(cannon.angle)

    repeat 100 times

    --- add gravity*step to vy

    --- add vx*step to x

    --- add vy*step to y

    --- create dot at (x,y)

  • It looks like it stops working, or at least jumps, when it goes to just one touch. Maybe setting the oldtouch value when a touch is released would alleviate that. I think I addressed that in my original capx, but I haven't looked.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you're not checking for performance with the sprite then disabling the collisions won't matter.

    Yeah, only the image size affects the amount of vram used. The size of the sprite doesn't matter. Also, there is no performance difference.

  • I wasn't aware there was a way to disable collisions. An "on collision" is basically a "is overlapping" with a trigger once. Collisions are only detected with a object if it either has the solid behavior or you use one of those events.

    The image size doesn't affect the performance. It just reduces the amount of vram used which can be important for mobile devices.

  • In 1 and 4 "this" is the current instance.

    In 2 "this" in the onCreate function is the current instance. It's set to a global variable so the instance can be referenced in that widow callback.

    In 3 self is used so the callback "errorFunc" can access the instance. Otherwise I think this would be the global window object.

    The following link probably is better help:

    http://javascriptissexy.com/understand- ... master-it/

  • From what I can tell the body is moved around directly and everything else: eyes, arms and legs point toward some target positions. I don't really see any physics other than the jump.

    This tutorial is relevant for the arms and legs I suppose. It's for construct classic but it explains it well, and all of it could be done in C2.

  • Physics engines usually do no conserve energy, there is loss over time. The reason is everything is an approximation. You can however keep the energy close to being constant by correcting the velocity.

    So the equation is this:

    E=KE+PE

    E=0.5*m*v^2 + m*g*h

    solved for v

    v = sqrt((E-mgh)*2/m)

    So the events to correct the velocity so energy is conserved would be:

    global number total_energy=0

    global number initial_y=0

    global number speed=0

    global number angleOfMotion=0

    Start of layout

    --- set initial_y to ball.y

    --- set total_energy to ball.physics.mass*10*(480-ball.y)

    ball: y<initial_y

    --- ball: set y to initial_y

    every tick

    --- set speed to sqrt((total_energy-ball.physics.mass*10*(480-ball.y))*2/ball.physics.mass)

    --- set angleOfMotion to angle(0,0,ball.physics.velocityX,ball.physics.velocityY)

    --- ball: physics: set velocity to ( speed*cos(angleOfMotion), speed*sin(angleOfMotion) )