All pastes #628403 Raw Edit

Stuff

public lua v1 · immutable
·published 2007-07-21 07:04 UTC
rendered paste body
--Hephaestus Pong like examplepongScene = scene:new() --Create a new scenepaddle = sprite:new("textures/paddle.png") --load a sprite, the paddlepaddle:reParentTo(pongScene) --The root node in the scene graph will                            --be the pongScenepaddle:setScale(1.0, 1.0) --Set the scale of the sprite, completely optionalpaddle:setPosition(10, 10) --Offset by it's parent.  (x, y) coordsposition = 10 --Remember, this is global without the "local" keywordfunction movePaddle()    paddle:setPosition(paddle:currentX() + position, paddle:currentY())    position = position + 1endpongScene:addTask("movePaddle")  --Add's a task to the pongScene's task                                --queue.  Every iteration of the scene                                --every task in the queue will be called once                                --per frame or at specific intervalsgame:pushScene(pongScene) --Game is the global game engine.  This pushes the                        --game state "pongScene" onto the game state machine's                        --stack.  We might want to make this an iterated queue                        --at some point if we need multiple states to run                        --concurrently.  Something to think about.