Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
MovieClip Noob Time! — Gideros Forum

MovieClip Noob Time!

AstirianAstirian Member
edited August 2016 in Game & application design
Hi guys,

So I think I'm getting the hang of Gideros :). I love the power and simplicity, especially coming from Obj-C and Marmalade Quick (which I found to be buggy).

Anyway, I'm at the point where I've got all my scrolling backgrounds working OK on my infinite runner prototype and started work on the player character. I've added a movieclip of him running so that's good, only thing I'm curious about is design-wise, should I stop the animation and set a single frame for when he jumps or something? I also need to add a physics body for collision detection but it feels weird adding a body to a movieclip.

I initially had a player sprite and was trying to add the movieclip to that sprite but it was just displaying both the clip and the original sprite, layered on top of each other.

All the best,
- D

Likes: antix

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • Hi @Astirian welcome aboard. Marmalade Quick was the framework I tried before I found Gideros. I also found it buggy (and slow on devices).

    Having a single frame animation for jumping is fine in most cases, it really comes down to what looks good to you. If you have assets with a running to jumping transition then I'd use that.

    Are you using simple rectangular shapes for collision or are you using something more complex like circles or triangles?



    Likes: simwhi

    +1 -1 (+1 / -0 )Share on Facebook
  • totebototebo Member
    edited August 2016
    Welcome to paradise! I tried Corona, Marmalade, Löve and a bunch other engines before settling on Gideros. Three years in it's still awesome, with fast iterations and a great community. It's become my tool of choice to make games professionally. Now. To your questions!

    In my current project I load and play all states, then hide the states I'm not using. This has the advantage of allowing seamless switching between states. My game is isometric-ish and it's nice to not interrupt the run cycle when changing direction. It may seem wasteful to always play the MovieClips, but performance is fine as long as you use setVisible().

    If you're thinking of using Box2D for collisions it's usually better to attach the graphic to the collision Body, rather than the other way around. Forcing the Body to move to where the graphic is can appear jumpy when a collision happens.

    Likes: simwhi, Astirian

    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 )Share on Facebook
  • Thanks for the replies guys! I'm loving this community already. :)

    I'll just be using basic rectangles for collision detection. The way I'd do it before is by creating a player sprite then assigning a frame animation to it for running, then for jumping I'd just assign the jump animation.

    I'd use something like player:setAnimation(run) in Marmalade, just not sure how to assign my MovieClip object to my player sprite in this instance though.

    At the moment I have this pretty much; my Player:init() creates the sprite in my Player core class. I add my running animation function in my player class then call everything from the game scene:
    Player = Core.class(Sprite)
     
    function Player:init()
        player = Bitmap.new(Texture.new("textures/player.png", true))
        player:setAnchorPoint(0.5, 0.5)
        player:setPosition(x=100, h-150)
        self:addChild(player)
    end
     
    function Player:animateRun()
        <do all the frame stuff...>
     
        local mc = MovieClip.new{
        frame stuff...
        }
     
        mc:setGotoAction(8, 1)
        player:addChild(mc) -- I've tried self:addChild(mc) here too.
        mc:play()
    end
    My player class is called in my game scene like so:
    player = Player.new()
    self:addChild(player)
    Then I try:
    player:animateRun()
    But I get two players, the original static sprite plus the player animation in a different spot on the screen (because I haven't given it coords, I guess).

    I'm sure I'm probably doing a couple of things wrong here. :)

  • I'd self:addChild() all states on init, then first hide all mcs with setVisible(false) and use setVisible(true) on the active state when needed.

    Likes: Astirian

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • I do all my animation for sprites manually by changing the texture for the bitmap - it only happens usually once every 4 frames or so max, so no big deal.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • @sinistersoft, do you have a nifty class for this or do you bake a new one per project?

    Likes: SinisterSoft

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • I just make it as I go, no classes for me... :)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Okay rectangle collision is pretty simple, so there's no need for an actual physics engine. There is a fantastic collision library called bump which you might want to have a look at. It is purpose made for AABB (rectangles) collisions. It contains some basic collision resolution also. Check it out here.

    With regards to your animation issues. Have you checked out the Bird and TexturePack example projects that come with Gideros? They will give you a better insight on how MovieClip works. If I get time today I'll throw together a small example for you too.

    Likes: n1cke, Astirian

    +1 -1 (+2 / -0 )Share on Facebook
  • antixantix Member
    edited August 2016 Accepted Answer
    @Astirian here is a small example project with multiple animations in a MovieClip.

    Using the controls you can run and jump about. If you fall off the green shapes or touch the red shape you die ("dead" animation plays).

    The code is not very well commented and a bit messy since I just tossed it together this afternoon but you should get the general idea from it I hope. If you have any questions just ask :)
    screendump.png
    496 x 380 - 12K
    zip
    zip
    MovieClip.zip
    172K
    +1 -1 (+2 / -0 )Share on Facebook
  • Thanks so much guys, I messed around with setVisible() a little this morning, pretty useful stuff but I'm still winding up assigning xPos to the frames individually.

    Thanks for the demo @antix! I'll try it now. :D Should keep me out of trouble for a little while.

    P.S Had a look at your games guys, they look great. @totebo nice pixel art on Miner Z! Do you do it yourself? I do mine myself but it takes so long, I'd be keen to outsource that.
  • @astirian, I've been lucky enough to work with great people in regards to the art. For No Brakes I did it all myself, which explains its minimalist feel. :)

    Likes: Astirian

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @Astirian I've signed up with an asset store (https://graphicriver.net/) and am going to make a bunch of small things where I can purchase the assets from there. They have a ton of pretty cheap quality assets ready to be used in games. BTW, they have heaps of cheap "infinite runner" type assets too :)
    +1 -1 (+2 / -0 )Share on Facebook
  • @Astirian I've signed up with an asset store (https://graphicriver.net/) and am going to make a bunch of small things where I can purchase the assets from there. They have a ton of pretty cheap quality assets ready to be used in games. BTW, they have heaps of cheap "infinite runner" type assets too :)
    I'm like a kid in a sweet shop! :D

    Likes: antix

    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    @Astirian be careful because you can endup spending more than you planned there. I have found myself browsing and thinking "wow I'm going to buy those assets and make a game based on them". I have to be very strict not to actually click the "purchase" button too much :D

    One thing to remember when viewing assets on stores is that most often they are NOT complete so whilst the assets on sale might be okay for one level of a game.. they are by no means ready for use in a game with more than one level.

    Likes: Astirian

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.