Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Moving images — Gideros Forum

Moving images

HarrisonHarrison Member
edited February 2014 in General questions
I just need to make my image move when the app is played. like... the x and a y smoothly gain 12 per second (for example purposes) How would i make my image update? I tried to implement a game loop and only succeed in crashing my gideros player. 30 mins of research later... nothing. :-?
“ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ” - Tom Cargill

Comments

  • @Harrison, not entirely sure on what you are after, have you tried reading my latest tutorial on http://howto.oz-apps.com ? It talks about scrolling and also about adding accelerometer to influence the same.

    link to the article http://howto.oz-apps.com/2014/02/viewing-image-like-in-facebook-paper-app.html
    twitter: @ozapps | http://www.oz-apps.com | http://howto.oz-apps.com | http://reviewme.oz-apps.com
    Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
    Cool Vizify Profile at https://www.vizify.com/oz-apps
  • thanks, i will look into it :)

    just to rephrase:
    image:setPosition(x,y)

    over and over again:
    x=x+1
    y=y+1
    end
    “ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ” - Tom Cargill
  • hmm... i guess i cant figure out event listeners, and that's the true problem..
    “ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ” - Tom Cargill
  • i think i figured it out - http://docs.giderosmobile.com/
    so... what are these event listener things?
    “ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ” - Tom Cargill
  • talistalis Guru
    edited February 2014
    Harrison you can use onEnterframe event to move your sprites. After having basic knowledge of events in Gideros i suggest you to look at those tutorials:
    http://blog.magnusviri.com/category/Gideros.html

    Of cource in addition to those ones please don't forget to visit this link:
    http://giderosmobile.com/guide

  • What you are looking for is probably something like this:
    --create a scene
    Scene = Core.class(Sprite)
     
    --scene constructor
    function Scene:init()
        --create an image
        self.myImage = Bitmap.new(Texture.new("myimage.png", true))
        self:addChild(self.myImage)
     
        --add enter frame event listener
        self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
    end
     
    --inside enterframe event listener
    function Scene:onEnterFrame()
        -- move your image by changing position
        self.myImage:setPosition(self.myImage:getX() + 1, self.myImage:getY()+1)
    end
     
    function Scene:destroy()
        --remove enter frame listener
        self:removeEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
    end
     
    local scene = Scene.new()
    stage:addChild(scene)
     
    --and when you don't need it anymore
    scene:destroy()
    stage:removeChild(scene)
Sign In or Register to comment.