Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Mi código no muestra los asteorides
Started by gspindolab Dec 01 2016 09:45 AM

2 replies to this topic
corona sdk
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

gspindolab

[GLOBAL: userInfoPane.html]
gspindolab
  • Observer

  • 1 posts
  • Corona SDK

Hola que tal tengo el siguiente código que viene en la página oficial.:

 

-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
 
-- Your code here
local physics = require( "physics" )
physics.start()
physics.setGravity( 0, 0 )
 
-- Seed the random number generator
math.randomseed( os.time() )
 
-- Configure image sheet
local options =
{
    frames =
    {
        {   -- 1) asteroid 1
            x = 0,
            y = 0,
            width = 102,
            height = 85
        },
        {   -- 2) asteroid 2
            x = 0,
            y = 85,
            width = 90,
            height = 83
        },
        {   -- 3) asteroid 3
            x = 0,
            y = 168,
            width = 100,
            height = 97
        },
        {   -- 4) ship
            x = 0,
            y = 265,
            width = 98,
            height = 79
        },
        {   -- 5) laser
            x = 98,
            y = 265,
            width = 14,
            height = 40
        },
    }
}
local objectSheet = graphics.newImageSheet( "gameObjects.png", options )
 
-- Initialize variables
local lives = 3
local score = 0
local died = false
 
local asteroidsTable = {}
 
local ship
local gameLoopTimer
local livesText
local scoreText
 
-- Set up display groups
local backGroup = display.newGroup()  -- Display group for the background image
local mainGroup = display.newGroup()  -- Display group for the ship, asteroids, lasers, etc.
local uiGroup = display.newGroup()    -- Display group for UI objects like the score
 
-- Load the background
local background = display.newImageRect( backGroup, "background.png", 800, 1400 )
background.x = display.contentCenterX
background.y = display.contentCenterY
 
ship = display.newImageRect( mainGroup, objectSheet, 4, 98, 79 )
ship.x = display.contentCenterX
ship.y = display.contentHeight - 100
physics.addBody( ship, { radius=30, isSensor=true } )
ship.myName = "ship"
 
-- Display lives and score
livesText = display.newText( uiGroup, "Vidas: "..lives, 200, 80, native.systemFont, 36 )
scoreText = display.newText( uiGroup, "Puntuación: "..score, 400, 80, native.systemFont, 36 )
 
-- Hide the status bar
display.setStatusBar( display.HiddenStatusBar )
 
 
local function updateText()
livesText.text = "Lives: "..lives
scoreText.text = "Score: "..score
end
 
local function createAsteroid()
 
    local newAsteroid = display.newImageRect( mainGroup, objectSheet, 1, 102, 85 )
    table.insert( asteroidsTable, newAsteroid )
    physics.addBody( newAsteroid, "dynamic", { radius=40, bounce=0.8 } )
    newAsteroid.myName = "asteroid"
end
 

El problema es que no se muestran los asteroides en pantalla, solo se muestra como en la imagén que adjuntare.

 

Espero puedan ayudarme con el problema. Gracias.

 

Attached Files



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hello,

Have you continued with the tutorial to the "Game Loop" section? This section should generate asteroids.

 

https://docs.coronalabs.com/guide/programming/03/index.html#game-loop

 

Brent



[TOPIC: post.html]
#3

dodi_games

[GLOBAL: userInfoPane.html]
dodi_games
  • Contributor

  • 355 posts
  • Corona SDK

Considero que debes seguir los consejos de Brent, el tutorial es por partes, continúa con el próximo capítulo, ánimo!


[topic_controls]
[/topic_controls]