Yann's Recent Forum Activity

  • you can start with that

    gridMovement.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 'cause the image point is at the center of the sprite. If I don't offset things by half the width and half the height you will have half the sprite out of layout. But maybe it's not a problem for you (:

  • hmmm try looking at tokenat and tokenCount system expression.

    http://www.scirra.com/manual/126/system-expressions

  • Dont use shape_1, shape_2 and shape_3 but an array

    Else you will have to rewrite the whole thing for each

    global text shape_all = "shape_red:shape_blue:shape_purple:shape_yellow:shape_green:shape_orange"
    global shapeCount = 3  // number of shape you want
    +System: on start of layout
      -> Array: set size to shapeCount,1,1
      + Array: foreach X elements
        -> Array: set value at (self.CurX) to "empty"
    +On What you want
      Local text tmp = ""  // copy to keep the original intact
      +repeat shapeCount times
        -> System: set tmp to shape_all
        -> Array: set value at loopindex to (tokenat(tmp,floor(random(tokencount(tmp,":"))),":"))
        -> System: set tmp to replace(tmp,Array.At(loopindex),"")
        -> System: set tmp to replace(tmp,"::",":")
        -> System: set tmp to (left(tmp,0,1) = ",") ? right(tmp,len(tmp)-1) : tmp
        -> System: set tmp to (right(tmp,len(tmp-1),1) = ",") ? left(tmp,len(tmp)-1) : tmp

    The four last actions are used to delete the token from the tmp string. This way you don't pick it again.

        -> System: set tmp to replace(tmp,Array.At(loopindex),"")

    Delete the token leaving the colons

    1:2:3 -> ":2:3" or "1::3" or "1:2:"

        -> System: set tmp to replace(tmp,"::",":")

    Check if there's two colons side to side and delete one

    1:2:3 -> ":2:3" or "1:3" or "1:2:"

        -> System: set tmp to (left(tmp,0,1) = ",") ? right(tmp,len(tmp)-1) : tmp

    Check if the first character is a colon and delete it

    1:2:3 -> "2:3" or "1:3" or "1:2:"

        -> System: set tmp to (right(tmp,len(tmp-1),1) = ",") ? left(tmp,len(tmp)-1) : tmp

    Check if there's a colon on the last character is a colon and delete it

    1:2:3 -> "2:3" or "1:3" or "1:2"

  • clamp just limit values between a minimum and a maximum

    self refers to the object from which you do the action.

    awesomeSprite: Set X to self.myVar

    is the same as

    awesomeSprite: Set X to awesomeSprite.myVar

  • Damn I've been Kyat ninja'd

    /On the layout there are four hidden objects called (book,table,spoon,lamp) each of them has at least 10 frames, so I can't create only one object and then calling a random frame.

    You can... And you should!

    Basically I would setup the layout this way:

    A Sprite called 'item' in which you put your animation of book,table,spoon,lamp.

    Name the animations properly.

    Then if you want to call a random object

    System: Create item
    item: set animation to tokenat( pool , floor( random( tokenCount(pool ,",") ) ), "," );

    If you want to pick a specific object and play his animation

    item: is animation "spoon" is playing
      -> item: start animation from current frame

    Little remarque on the last one: even if the animation is stopped as long as you display a frame from a specific animation the "is animation playing" is true.

    In short you can use the name of the animation as... naming as you implied I think.

    Also, if you have many animation per object, you can still use the name as a prefix

    spoon_idle, spoon_run (oh noes a running spoon /o/)

  • Ok, I think we are running in circle, you should describe a bit more about your game, the solution might be quite simple, but just asking for some specific feature might not be the correct angle to tackle this problem.

  • put all the hud object in a family

    global number mXStart = 0
    global number mYStart = 0
    System: On start of layout
      -> hudFamily set xStart to self.X
      -> hudFamily set yStart to self.Y
    Mouse: on Left Click
      -> System: set mXStart to mouse.X
      -> System: set mYStart to mouse.Y
    Mouse: left button is down
      -> hudFamily set X to self.xStart+mouse.X-mXStart
      -> hudFamily set Y to self.yStart+mouse.Y-mYStart
  • The question you have to ask yourself is why you want to pick a specific instance instead of another. By answering this question you'll find how to pick it.

    For example if you want to pick a specific instance because it's underneath the cursor

    +Mouse: is over Sprite
      -> Sprite: set myCustomID to 1
  • System: on start of layout
      Local number curFrame = 0
      -> System curFrame = Sprite.AnimationFrame
      -> Sprite: set frame to 4
      -> Text: set text to Sprite.ImageWidth
      -> Sprite: set frame to curFrame

    Doesn't work?

  • nope Unique ID and Instance ID are automatically assigned on creation

    By setting a unique ID arbitrary you would have risked it to not be unique anymore...

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann