R0J0hound's Forum Posts

  • It's the same if you created a sprite in a function. If you create another, it will exist till you destroy it. Also an object's uid should never change. I've resized many arrays and their uid remains the same.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe this?

    (1-value/180)*100

  • I don't quite understand the first bit. Do you want the direction the enemy is moving or the direction from the enemy to the player?

    if you're using a behavior they often have a angleofmotion expression or x and y velocity expressions from which you can calculate the angle of motion with angle(0,0,veloctyx,velocityY).

    As for calculating a value of 0 to 7 for animation.

    This converts a from the range (-180,180) to (0,360):

    (a+360)%360

    This rounds the angle to the nearest 45degree angle 0 to 7. The 22.5 is half of 45 and is needed to round correctly.

    Int((a+22.5)/45)

    Edit:

    If you are using the move at angle action to move the object then you should keep track of the direction you moved. Another way is to save the objects position to variables oldx and oldy before you move and calculate the angle of motion with angle(oldx,oldy,sprite.x,sprite.y) after you move.

  • What you're trying to do is what is called "pass by reference" in other programming languages, which just passes the variable to modify to the function. C2 functions can't do that, it only does "pass by value", so the function has no idea where the values came from.

    So like you said you can do a function for each or re-work your function.

    On function "weapon leveling"

    Pick ship by uid function.param(0)

    --- function param 1= "rate"

    ------ events to level up rate

    --- function param 1="speed"

    ------ events to level up speed

    ....

    Then call the function with

    Call function "weapon leveling" (ship.uid, "speed")

    You'll still be duplicating events but they'll all be in that function.

  • Search for "gesture recognition" for a few examples that may help.

    What is usually done is to compare the points of the line drawn instead of the resulting image.

    One way is to evenly divide the drawn stroke and compare that with a saved stroke. The simplest way is if both strokes have the same number of points, but you can do some interpolation if the number is different.

    The comparison can compare the direction or positions of the points. If by location you'll need to scale the strokes to be the same size.

    For each point you add up the differences. Then that sum will indicate how similar the two shapes are. 0 would be identical and anything higher would be less similar. Typically you pick a number that would be good enough to consider it that shape.

    For comparing against multiple shape you'd do the same for each and keep the one that was closest.

    For comparing if a triangle was drawn then you would have to have to do something a bit more clever. Since you could have started drawing the triangle from any point and went either direction.

    One idea would be to find the center of the stroke and find the distances around that to the point. Then you could compare the distances of both strokes at the same angles around the shape.

    Anyway, just some ideas. I've made an example that you can find by searching that does some of the above. There are also some examples made by others as well as a plugin that could be of use.

  • You can make the bullet behavior not affect the sprite's angle by setting it's "set angle" property to "no".

  • Yeah, the calculation was done manually based on imagewidth*imageheight*4 as I recall.

  • I don't have access to C2 at the moment, but...

    4. I thought there was. At least you can scale the tiles up for sure. I'd assume it can go the other way.

    5. I could be remembering wrong but I thought if you right clicked the animation name then preview was one of the options.

    6. If you closed the image editor and you didn't want that change, you can use undo to revert it.

  • Neither. When you call a function only numbers or text is passed. The function has no knowledge of what variables were used.

    Consider your function call:

    Call "weaponleveling" (ship.bulletexpspeed, ship.bulletlvlspeed)

    If those two variables were 100 and 15 respectfully then this call would be identical:

    Call "weaponleveling" (100,15)

    If you want to modify a variable of a certain instance with a function then you need to pass that instance's uid as one of the parameters and then pick by uid in the function to modify the variables.

    Also as blackhornet stated a function has only one return value. if you set the return variable multiple times then only the last value will be used.

    The main purpose of a return value is when you call a function from an expression. Like this:

    On function "add"

    --- set return value to function.param(0)+function.param(1)

    Global number sum=0

    Start of layout

    --- set sum to function.call(100,15)

  • You can have the bullet behavior bounce off solids, but the physics behavior needs the other objects to have physics to work. The physics behavior will give more realistic bounces though. The third option would be to do your own physics with events, but this isn't by any means simple.

  • This should do it if you give the balls two instance variables dx and dy:

    start of layout:
    --- ball: set dx to self.x-rhomb.x
    --- ball: set dy to self.y-rhomb.y
    
    global number t=0
    
    every tick:
    --- set t to cosp(1, 0.5, time)
    --- ball: set x to rhomb.x+lerp(0,self.dx,t)
    --- ball: set y to rhomb.y+lerp(0,self.dy,t)
    --- ball: set size to (lerp(0,32,t), lerp(0,32,t))[/code:3p4f7h1b]
    
    The cosp() equation is the only one you'd need to tweak.
    With cosp(1, 0.5, time) it will take one second to go from full size (32,32) to half size (16,16), and another second to go back to full size.
    
    1 is full size and 0.5 is half.  You can change those.
    You can make it go twice as fast if you multiply time by 2.  To make it half as fast multiply by 0.5.
  • Couldn't you just use touch.X instead of converting touch.absoluteX?

    Touch.x gives you the x on the layout.

    You can also use Touch.X("layer") to get an x relative to a layer. If you want a position on a hud layer that doesn't scroll, this would do it.

    If you're intent on finding why

    Touch.AbsoluteX/(WindowWidth/1280) is equal to 640 instead of 1280, take a look at the values of Touch.AbsoluteX and WindowWidth. It could be a high dpi feature of your mobile or something of that effect. There's a project setting for that that you could probably fiddle with.

  • Another way would be to use a Boolean variable "moving" and set it to true every time you change the object's position.

  • Those are effects for Construct Classic.

    Here is a list of effects for C2:

  • It's one of the plugins where the source wasn't provided. There likely are some functions in the runtime that enable that plugin to work though.